[Bug c++/39934] Union member incorrectly disallowed
redi at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Nov 3 18:10:00 GMT 2009
------- Comment #8 from redi at gcc dot gnu dot org 2009-11-03 18:10 -------
(In reply to comment #6)
>
> The ARM comment (as quoted) is clearly wrong: offhand, I can think of
> two other ways of getting an object initialized. There are probably
> more.
>
> 1. Casting the offending "const" away. (Note that struct A is a plain
> old C type -- data members only.)
It's irrelevant that it has data members only. Casting away const on an object
declared const is undefined behaviour.
> 2. Copying an existing object.
>
> A a (*pa);
Copy construction is dealt with separately from copy assignment, so
has_complex_assign_ref is not relevant in this case.
So the ARM comment may be incorrect, but not due to either of your reasons.
As I said earlier, I'm not sure whether using A in a union causes the
implicitly-declared copy assignment operator to be implicitly defined. This
issue hinges on that point, not on the points you've been making.
The standard is clear that a copy assignment operator is implicitly-declared.
If it is implicitly defined then that copy assignment operator would be
ill-formed.
So the only question is whether using the type in a union causes it to be
implicitly defined.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39934
More information about the Gcc-bugs
mailing list