gdb vs. static fixed array member

Yotam Medini yotamm@tmai.com
Tue Sep 23 13:05:00 GMT 1997


Here is small example, in which gdb does Segmentation Fault.

The source:

   telaviv:501> cat c.h
   #ifndef _C_H
   #define _C_H

   class C
   {
    public:
      int                    i;
      static const unsigned  sua[];
   };

   #endif /* _C_H */
   telaviv:502> cat c.cc
   #include "c.h"

   const unsigned  C::sua[] = {1, 9, 7, 7};
   telaviv:503> cat m.cc
   #include "c.h"

   int main(int, char**)
   {
      C  c;
      return 0;
   }

Now, I compiled and run via debugger printing the 'c' object.
All under:
   telaviv:510> uname -a
   SunOS telaviv 5.5 Generic sun4u

* SunCC with dbx worked fine.
* g++ 2.7.2 with gdb 4.16 failed.
* egcs/g++ (gcc version egcs-2.90.08 970917) with gdb 4.16 failed.

   telaviv:504> make CXX=CC clean m
   CC -g -c m.cc
   CC -g -c c.cc
   CC -g -o m.new m.o c.o
   mv m.new m
   telaviv:505> dbx m
   WARNING: terminal is not fully functional^M
   ^M-  (press RETURN)q
   ^M^MReading symbolic information for m
   Reading symbolic information for rtld /usr/lib/ld.so.1
   Reading symbolic information for libm.so.1
   Reading symbolic information for libC.so.5
   Reading symbolic information for libw.so.1
   Reading symbolic information for libc.so.1
   Reading symbolic information for libdl.so.1
   Reading symbolic information for libc_psr.so.1
   (dbx) (dbx) stop in main
   (2) stop in main
   (dbx) run
   Running: m 
   (process id 10659)
   stopped in main at line 6 in file "m.cc"
       6      return 0;
   (dbx) print c
   c = {
       i   = -268440320
       sua = (1U, 9U, 7U, 7U)
   }
   (dbx) quit
   telaviv:506> make CXX=g++ clean m
   g++ -g -c m.cc
   g++ -g -c c.cc
   g++ -g -o m.new m.o c.o
   mv m.new m
   telaviv:507> gdb m
   GDB is free software and you are welcome to distribute copies of it
    under certain conditions; type "show copying" to see the conditions.
   There is absolutely no warranty for GDB; type "show warranty" for details.
   GDB 4.16 (sparc-sun-solaris2.5), Copyright 1996 Free Software Foundation, Inc...
   (gdb) break main
   Breakpoint 1 at 0x10b98: file m.cc, line 6.
   (gdb) run
   Starting program: /home/yotamm/C/egcs.bugs/m 

   Breakpoint 1, main () at m.cc:6
   6	   return 0;
   (gdb) print c
   $1 = {i = -268440220, Segmentation Fault
   telaviv:508> make CXX=egcs++ clean m
   egcs++ -g -c m.cc
   egcs++ -g -c c.cc
   egcs++ -g -o m.new m.o c.o
   mv m.new m
   telaviv:509> gdb m
   GDB is free software and you are welcome to distribute copies of it
    under certain conditions; type "show copying" to see the conditions.
   There is absolutely no warranty for GDB; type "show warranty" for details.
   GDB 4.16 (sparc-sun-solaris2.5), Copyright 1996 Free Software Foundation, Inc...
   (gdb) break main
   Breakpoint 1 at 0x105c4: file m.cc, line 6.
   (gdb) break main
   Note: breakpoint 1 also set at pc 0x105c4.
   Breakpoint 2 at 0x105c4: file m.cc, line 6.
   (gdb) run
   Starting program: /home/yotamm/C/egcs.bugs/m 

   Breakpoint 1, main () at m.cc:6
   6	   return 0;
   (gdb) print c
   $1 = {i = -268440220, Segmentation Fault


Hope this will help. -- yotam



More information about the Gcc-bugs mailing list