core dump using pow and structures with egcs
Andy Loening
loening@ucla.edu
Mon Jul 12 19:57:00 GMT 1999
Hello People,
I might have a bug for you guys to chew on here. From what I can tell,
this is the simplest case I could come up with. I did need three elements
in the structure and two pows to produce this bug.
test.c
------------------------------------------------------------------
#include <math.h>
typedef struct {
double x;
double y;
double z;
} RealPoint;
int main (void) {
RealPoint p1 = {25.0, 25.0, 25.0};
double a;
a = (pow(3,2)+pow(4,2));
return;
}
---------------------------------------------------------------
When I compile and run this, I get a core dump. I'm compiling with:
"egcs -lm -Ox -o test test.c"
where x is 2 or 3.
This is a redhat 6.0 gnu/linux box and "egcs -v" gives me
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
I also get the same thing on a mandrake 5.3 gnu/linux box where
"egcs -v" gives me: gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)
In this case, any optimization level will cause the crash. Note that gcc
version 2.7.2.3 on this box does not give this behaviour.
So, I compiled with -ggdb (this is back on the redhat 6.0 based system,
egcs version 1.1.2) did a bt in gdb, and this is what I get:
------------------------------------------------------------------
Core was generated by `./test'. Program terminated with signal 11,
Segmentation fault. Reading symbols from
/opt/rsi/idl_5.2/bin/bin.linux/__setfpucw.so...done.
Reading symbols from /lib/libm.so.6...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/ld-linux.so.2...done.
#0 0x8048515 in main () at /usr/include/bits/mathinline.h:376 376
__inline_mathcode2 (pow, __x, __y, \
(gdb) bt
#0 0x8048515 in main () at /usr/include/bits/mathinline.h:376
#1 0x4004fcb3 in __libc_start_main (main=0x8048440 <main>, argc=1,
argv=0xbffffb84, init=0x8048310 <_init>, fini=0x80485bc <_fini>,
rtld_fini=0x4000a350 <_dl_fini>, stack_end=0xbffffb7c)
at ../sysdeps/generic/libc-start.c:78
----------------------------------------------------------------
If you guys want any more information, please feel free to get in touch
with me (loening@ucla.edu). Oh, and I'm not on this list, so replying to
the list won't send anything to me.
Thanks,
Andy
More information about the Gcc-bugs
mailing list