Bug 50488

Summary: Destructor problem in struct
Product: gcc Reporter: karman <inexinferis>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED WORKSFORME    
Severity: normal    
Priority: P3    
Version: 3.4.5   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description karman 2011-09-22 17:46:02 UTC
Hi I have this problem and I'm not sure if it's a bug but I guess you can help me...

class x{
  public:
  x(){printf("cok %p\n",this);}
  ~x(){printf("dok %p\n",this);}
};

static struct _a{
  int a;
  x b;
}a[]={
  {1}
};

int main(void){
  x a;
  return 0;
}

the result:

cok 0022FF14
cok 0022FF40
dok 0022FF40
dok 0040800C //<-- what???

Regards
Comment 1 Jonathan Wakely 2011-09-22 17:52:00 UTC
you have two problems, one is that the code won't compile because you're missing a header, the second is that GCC 3.4.5 is ancient, so although this does appear to be a bug it will never be fixed in GCC 3.4 (it's already fixed in current releases)
Comment 2 Andrew Pinski 2011-09-22 18:11:03 UTC
Also I think he forgot about copy constructor happening.
Comment 3 karman 2011-09-22 18:12:18 UTC
(In reply to comment #1)
> you have two problems, one is that the code won't compile because you're
> missing a header, the second is that GCC 3.4.5 is ancient, so although this
> does appear to be a bug it will never be fixed in GCC 3.4 (it's already fixed
> in current releases)

Yes, the thing is that all my projects are working over GCC 3.4.5 and my attempts to ports to 4.x was with problems, in conclusion, I have to migrate to GCC 4.x or there is a chance to fix?

Regards
Comment 4 Jonathan Wakely 2011-09-22 18:41:41 UTC
GCC is open source so you can attempt to fix it yourself or pay someone to do it for you, but it will never be fixed in the official GCC 3.4 because that release series is discontinued and unsupported
Comment 5 karman 2011-09-22 18:43:30 UTC
ha, ok, thanks.