This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bug in GCC or C++ standard ?
On Tue, Nov 11, 2008 at 08:43:40PM -0800, James Dennett wrote:
> (There are secondary uses of unions for type punning. Most such uses
> are not valid portable C++, but g++ supports them because they're so
> common in real code.)
On the contrary: the uses of unions for type-punning, while not portable,
are valid C++, and while not portable, the behavior is
implementation-defined (because it exposes the bitwise implementation of C
and C++ types). Without this feature, it would not be possible to
implement a function like ldexp or frexp in C or C++, where we want
to consider the same storage either as a double or as a sequence of
bytes.
This doesn't change your main point: asking that the compiler support
initializers for more than one element of a union makes no sense.