
18 Apr
2008
18 Apr
'08
10:52 p.m.
[mailto:boost-bounces@lists.boost.org] On Behalf Of Roland Schwarz Teemu Torma wrote:
Wouldn't casting using union be safe and efficient in all cases?
I don't know anything about the specific problem at hand, but this hopefully is in carefully controlled code, i.e. platform dependant and the like. AFAIK this usage is not std c++. (But I might be wrong.)
No I think your right. Reading a member of a union other than the last one written to is undefined behavior. See #97 in Sutter-2005 or #C.8.2 in Stroustrup-2000, they both advise strongly against trying this.