[Bug c++/35548] g++ 4.3.{0,1} miscompile this simple program

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Mar 12 10:20:00 GMT 2008



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-03-12 10:19 -------
It's by no means a "simple" program ;)

the failure mode is that

Program received signal SIGSEGV, Segmentation fault.
0x0000000000400bed in basic::compare (this=0x603040, other=@0x603010) at t.C:98
98                              return compare_same_type(other);
(gdb) print other
$1 = (const basic &) @0x603010: {<refcounted> = {refcount = 1}, 
  _vptr.basic = 0x401430, static tinfo_static = {<No data fields>}, 
  tinfo_key = 0x401365, flags = 3}
(gdb) print *this
$3 = {<refcounted> = {refcount = 0}, _vptr.basic = 0x0, 
  static tinfo_static = {<No data fields>}, tinfo_key = 0x401365, flags = 3}

the object compare is invoked on is not properly initialized (its _vptr is
NULL).

(gdb) bt
#0  0x0000000000400bed in basic::compare (this=0x603040, other=@0x603010)
    at t.C:98
#1  0x0000000000400f41 in ex::compare (this=0x7fff106c4510, 
    other=@0x7fff106c44e0) at t.C:165
#2  0x00000000004009a8 in main (argc=1, argv=0x7fff106c4628) at t.C:213

For whatever reason (program non-conformance or GCC bug).

Please try to simplify the test program.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35548



More information about the Gcc-bugs mailing list