This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc "bug"
- From: Jeffrey Hammel <jhammel at EECS dot Berkeley dot EDU>
- To: gcc-bugs at gcc dot gnu dot org
- Cc: alanwu at langmuir dot eecs dot berkeley dot edu
- Date: Mon, 16 Feb 2004 13:39:39 -0800 (PST)
- Subject: gcc "bug"
Hello,
A possible "bug" in gcc (or "feature"?): when linking to libraries
without header files, gcc will give no error or warning BUT the library
calls will not give the correct results. A simple program:
gcc-bug.c:
#include<stdio.h>
main() { printf("\n%g\n", log(2.71)); }
Note here that math.h is NOT included (though should be).
output:
[jhammel@darkstar jhammel]$ gcc gcc-bug.c -lm
[jhammel@darkstar jhammel]$ ./a.out
-1.99859
[jhammel@darkstar jhammel]$
If math.h is included, the correct result (0.996949) is of course
produced.
System information:
* gcc --version
gcc (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
* Athlon 2200+
If this is a bug, please fix. If its a "feature", it is certainly
counter-intuitive to us mere application programmers. I apologize greatly
for not verbosely following the procedures for reporting gcc bugs, but
figure that this should be plenty of info for you. If this has been fixed
in later gcc versions, I apologize even more so.
Jeff Hammel
Plasma Theory and Simulation Group
UC Berkeley