Re: Unions destructors and GC precision

2012-08-15 Thread bearophile
Paulo Pinto: Same thing about unions, as you wouldn't know which pointer/reference is the active one without some kind of tagging. But with a standard method like activeField the tagging doesn't need to be explicit. Bye, bearophile

Re: Unions destructors and GC precision

2012-08-14 Thread Simen Kjaeraas
On Wed, 15 Aug 2012 07:09:40 +0200, Jonathan M Davis wrote: On Wednesday, August 15, 2012 07:02:25 Simen Kjaeraas wrote: On Tue, 14 Aug 2012 22:32:58 +0200, Andrei Alexandrescu wrote: > On 8/14/12 3:25 PM, bearophile wrote: >> D2 doesn't give you that restriction, and when an union goes ou

Re: Unions destructors and GC precision

2012-08-14 Thread Paulo Pinto
On Wednesday, 15 August 2012 at 05:10:02 UTC, Jonathan M Davis wrote: On Wednesday, August 15, 2012 07:02:25 Simen Kjaeraas wrote: On Tue, 14 Aug 2012 22:32:58 +0200, Andrei Alexandrescu wrote: > On 8/14/12 3:25 PM, bearophile wrote: >> D2 doesn't give you that restriction, and when an union

Re: Unions destructors and GC precision

2012-08-14 Thread Jonathan M Davis
On Wednesday, August 15, 2012 07:02:25 Simen Kjaeraas wrote: > On Tue, 14 Aug 2012 22:32:58 +0200, Andrei Alexandrescu > > wrote: > > On 8/14/12 3:25 PM, bearophile wrote: > >> D2 doesn't give you that restriction, and when an union goes out of > > > >> scope it calls the destructors of all its

Re: Unions destructors and GC precision

2012-08-14 Thread Simen Kjaeraas
On Tue, 14 Aug 2012 22:32:58 +0200, Andrei Alexandrescu wrote: On 8/14/12 3:25 PM, bearophile wrote: D2 doesn't give you that restriction, and when an union goes out of scope it calls the destructors of all its fields: That's pretty surprising. "Major bug" doesn't begin to describe it. Un

Re: Unions destructors and GC precision

2012-08-14 Thread bearophile
Andrei Alexandrescu: That's pretty surprising. "Major bug" doesn't begin to describe it. If you want later I will add it to Bugzilla. But maybe before that other people will want to write some other comments in this thread. Unions should call no constructors and no destructors. But thi

Re: Unions destructors and GC precision

2012-08-14 Thread Andrei Alexandrescu
On 8/14/12 3:25 PM, bearophile wrote: D2 doesn't give you that restriction, and when an union goes out of scope it calls the destructors of all its fields: That's pretty surprising. "Major bug" doesn't begin to describe it. Unions should call no constructors and no destructors. Andrei

Unions destructors and GC precision

2012-08-14 Thread bearophile
Before C++11 you weren't allowed to write something like: union U { int x; std::vector v; } myu; because v has an elaborate destructor. In C++11 they have added "Unrestricted unions", already present in g++ since version 4.6: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2