|
Boost Users : |
Subject: Re: [Boost-users] [Off topic] Strict Aliasing white paper redux
From: Patrick Horgan (phorgan1_at_[hidden])
Date: 2011-01-03 19:38:04
On 01/03/2011 08:01 AM, Dave Abrahams wrote:
> At Mon, 03 Jan 2011 00:08:23 -0800,
> Patrick Horgan wrote:
>> I'm not so sure. This idiom has been around as long as unions were in
>> C. Do you know of any compilers that don't support it? Of course
>> memcpy or any other solution using character pointers would be
>> supported, but compilers wouldn't generate efficient code for in this
>> case a simple swap of 16 bit ints. Clearly the specs say that a union
>> can only contain one object at a time. Hmmm. The C99 spec has a
>> footnote to section 6.5.2.3/3 that seems to clearly say you can do
>> this
> The C99 spec is irrelevant to C++; it isn't even "included by
> reference," as the C89 spec is.
Good point Dave, but I think I've let go of it as a possibility for C++
anyway. I'll have to rewrite that part. The C spec also mentions
things about how non-share parts become undefined when switching to a
different member of the union, but since the C++ spec calls for
destruction and in place construction to switch, it's clearly out.
Patrick
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net