[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

howto identify missing stdlib.h after compile?



Unless I compile with -Wall, following code compiles with no warning
with "gcc -g -o example example.c".

How should I tell that this code is broke after compile?
----------
# include <stdio.h>
/*# include <stdlib.h>*/ /*Not to have this for atof is the bug*/
int main(int argc, char **argv) {
float x=0;
x=atof("123.456");
printf("%8.4f\n",x);
return 0;
}
----------------
$ ./example
1078984704.0000
$
----------------
FYI:
"nm example" produces: (Same with or without bug.)
...
080482bc ? _init
08048350 T _start
         U atof@@GLIBC_2.0
080494c8 d completed.4
...

The only difference with correct program is:
@@ -1,5 +1,5 @@
 08048374 t Letext
-08048452 t Letext
+08048457 t Letext
 08049504 ? _DYNAMIC
 080494e0 ? _GLOBAL_OFFSET_TABLE_
 080484ac R _IO_stdin_used
    
I can not tell from this that this program is broke. gdb print same as
printf.
-- 
~\^o^/~~~ ~\^.^/~~~ ~\^*^/~~~ ~\^_^/~~~ ~\^+^/~~~ ~\^:^/~~~ ~\^v^/~~~ 
+  Osamu Aoki <debian@aokiconsulting.com>, GnuPG-key: 1024D/D5DE453D  +
+  For my debian quick-reference, peek into:                          +
+                               http://www.aokiconsulting.com/quick/  +



Reply to: