This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] C++ miscompilation with ctors and dtors

Hoping to raise some interest in fixing this bug[*]: PR 12751 has an example 
which shows that the tree-ssa branch generates code with a different number 
of destructors than constructors. I took the time to reduce it to something 
small and tractable:
extern int printf (__const char *__restrict __format, ...) throw ();

struct Y {
    Y() { printf("Y::Y\n");}
    ~Y() { printf("Y::~Y\n"); }

int main() {
  Y y1;
  Y y2;
  switch(0) {
    case 1:
        Y y3;
        return 0;
Obviously, two Y objects should be generated, and they should subsequently be 
destroyed again. Alas, this is what I get:
g/x> /home/bangerth/bin/gcc-tree-ssa/bin/c++ && ./a.out

Does someone have any insight into why this happens and what can be done about 
it? In a related PR, the double destruction leads to memory corruption and 
from there on nothing will work, of course. This strikes me as serious enough 
that it would be worth fixing ASAP.


[*] I raise this for very selfish motives: as Andrew pointed out, PR 12751 is 
likely a duplicate of my own PR 12789. The latter is a miscompilation that 
happens in the program that generate the Makefile dependency lists for the 
files of our library -- without it I can't even begin to compile my library 
with the tree-ssa branch, and I can't thus inform you of all the bugs I will 
find in the tree-ssa branc of gcc...
Wolfgang Bangerth              email:  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]