debug/2286: Simplified c++/1657: types weirdness (looks like memory corruption with -ggdb)

wolfgang.bangerth@iwr.uni-heidelberg.de wolfgang.bangerth@iwr.uni-heidelberg.de
Wed Mar 14 02:26:00 GMT 2001


>Number:         2286
>Category:       debug
>Synopsis:       Simplified c++/1657: types weirdness (looks like memory corruption with -ggdb)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 14 02:26:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang Bangerth
>Release:        unknown-1.0
>Organization:
>Environment:
Sun Solaris, x86 Linux, gcc CVS
>Description:
This is a greatly simplified version of c++/1657 that should
make it significantly simpler to track down the problem as
it only contains 18 preprocessed lines. The problem still exists
with todays CodeSourcery snapshot. Note that the error is
a) unwarranted,
b) only occurs if I have struct X in the code, which is
nowhere referenced, however,
c) goes away if I replace -ggdb with -g. I guess that both
Solaris and Linux use DWARF-2.

Regards
  Wolfgang

-----------------------------
struct X {
    const int x[4];
};

struct A {
    A();
    A(const A&);
};

struct B {
    A a;
    int b[4];
};

struct C {
    A a;
    C() {  B b=B();   };
};
-----------------------------------------

/t> c++ -ggdb -c tt.cc -o /dev/null
tt.cc: In copy constructor `B::B(const B&)':
tt.cc:17: incompatible types in assignment of `const int[4]' to `int[4]'

>How-To-Repeat:
c++ -ggdb -c tt.cc
>Fix:
I'd guess that it is due to some code writing out debug info
for X::x and B::B and that there is a check whether the type
has previously been used to that we can reference the type
in the second place. It might well be that the check is mistyped
as
  if (type1 = type2)
changing the type of B::b to being constant, which then
yields the error. This must be somewhere in the DWARF-2
output routines. However, this is only a wild guess.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list