« first day (1198 days earlier)      last day (2658 days later) » 

07:52
@Owatch I actually laughed very hard on this, nice one :)
 
1 hour later…
09:11
@Unknown123 nothing, windows, makes u look as a duffer in usual basis
 
2 hours later…
10:42
@DrorK. you around?
The compiler can (and should) make the initial assumption only if the right standard headers are included (at the right place). — Basile Starynkevitch 41 mins ago
142k and so wrong
@BasileStarynkevitch that's incorrect. "All identifiers with external linkage in any of the following subclauses (including the future library directions) and errno are always reserved for use as identifiers with external linkage." — Antti Haapala 12 mins ago
 
2 hours later…
12:30
@AnttiHaapala that's why I keep saying, that reputations don't matter anymore -- hence I stopped collecting them years ago..
12:42
@PeterVaro as far i assume, a function's definition is tied to what it is in standard library, unless you redefine it, for instance sqrt(double) redefines the function as a reference to different call signature than it is inthe standard, so without this aforementioned definition, the compiler still thinks it is sqrt(int) right ?
hi all
what uses of function pointers have you found in your work/ project?
@Idle001 there are 2 kinds of assumptions: those which are right and those wrong
@user2713461 the only use. Putting a pointer to function in a variable so that it can be called.
still just an assumtion not an assertion
it's better that you didn't assert:D
you would have been aborted.
@AnttiHaapala so it can be called as function parameter?
12:48
@Idle001 the C standard says that use of sqrt as an identifier in a definition with external linkage will have undefined behaviour, period.
there are no exceptions.
these assumptions all arise because one and one reason only: learning C from bad books, or by reading C code or by trial-and-error...
@AnttiHaapala yes let's forget about the 'int' part, but still it doesnt make an explanation to me why the compiler fires an error with user inserted value ?
compiler doesn't fire that error
that error is from linker
the user entering the value is the easiest way to ensure that it cannot be optimized out.
the error happens because the linker didn't find sqrt because the -lm switch was not specified.
the first one didn't error because there was no trace of sqrt left. All there was in the object that was being linked: the double value 2.0
yes thanks for this important note, actually i did't learn C from bad books but some bad recurrent trial&errors
that's the worst kind.
... and that's what I've done too :D
i know .... i know
which means the double value isn't to be processed by the linker in the second shot, got it
no, linker doesn't process double values.
it links a bunch of object files representing individual translation units into one program by linking the use of a symbol (such as sqrt) to its actual definition in another module
all of my code there compiles, but not all links.
% gcc -c foo.c
this compiles only
it works without problems. When you try to link them into a program
% gcc foo.o -o program
foo.o: In function `main':
foo.c:(.text+0x19): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
then you'll have the error, if any
the fix is
% gcc foo.o -o program -lm
13:22
@AnttiHaapala so .... following my trudging understanding of things, in the first example the compiler haven't stumbled into a linking problem because sqrt(4.0) was dealt with as a constant, it hasn't had to link it which explains the success even when -lm flag is skipped
@Idle001 well, compiler doesn't stumble into a linking problem, it is the linker, but yes.
thanks for this tip though
the gcc is not the C compiler. It is the compiler driver, which can compile in various languages, assemble, preprocess and link
DESCRIPTION
       When you invoke GCC, it normally does preprocessing, compilation, assembly and linking.  The "overall options"
       allow you to stop this process at an intermediate stage.  For example, the -c option says not to run the
       linker.  Then the output consists of object files output by the assembler.
@Idle001 btw, this is interesting:
GCC 7 can determine the return value or range of return values of some calls to the sprintf family of functions and make it available to other optimization passes. Some calls to the snprintf function with a zero size argument can be folded into constants. This optimization is included in -O1 and can be selectively controlled by the -fprintf-return-value option.
-Wpointer-compare warns when a pointer is compared with a zero character constant. Such code is now invalid in C++11 and GCC rejects it. This warning is enabled by default.
I am going to use this in my programs from now on :D
13:43
@AnttiHaapala something like this ?
@Idle001 yes, that's completely legal C.
but doesn't compile in C++ now :D
so it would stop stupid people from compiling my things with a C++ compiler

« first day (1198 days earlier)      last day (2658 days later) »