This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/39934] Union member incorrectly disallowed
- From: "terra at gnome dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Nov 2009 13:47:34 -0000
- Subject: [Bug c++/39934] Union member incorrectly disallowed
- References: <bug-39934-9033@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from terra at gnome dot org 2009-11-03 13:47 -------
> I'm not sure whether using A in a union causes the implicitly-declared copy
> assignment operator to be implicitly defined, but that seems to be what's
> happening.
No, that's not quite it.
The requirement for union members is that there cannot be a non-trivial copy
assignment operator.
gcc uses a different rule: it insists that there be a default copy assignment
operator.
Presumably someone thought those two formulations were the same. But they
are not: struct A doesn't have a copy assignment operator at all.
For the record, this kind of code occurs fairly naturally in C when creating
trees with different node types, tagged here by "x". The problems arise when
C++ code needs to interface with that C code.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39934