Warning
Derek Parnell
derek at psych.ward
Thu Feb 23 07:52:27 PST 2006
On Fri, 24 Feb 2006 02:48:38 +1100, Georg Wrede <georg.wrede at nospam.org>
wrote:
> Derek Parnell wrote:
>
>> Sorry, but I forgot something nice. Anonymous structs don't seem to be
>> solving any problem that I've come across, but anonymous unions are very
>> nice.
>> struct S
>> {
>> int type;
>> union { int i; long l;
>> short s;
>> real r;
>> float f;
>> Foo foo;
>> }
>> }
>
> Of course you know, and all regulars here know, but the casual reader
> has to be warned here.
>
> NEVER MIX VALUE AND REFERENCE types in a union!
>
> While technically it poses no problem, in real life you'll end up
> shooting yourself in the foot -- faster than it takes to say 'Ouch!'
>
> And if you don't, the later maintainer of your code *will* shoot you.
Sorry, but maybe I should have also mentioned ...
alias char Foo; <g>
--
Derek Parnell
Melbourne, Australia
More information about the Digitalmars-d
mailing list