This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Anonymous union assignment problem
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Anonymous union assignment problem
- From: Stefan Westerfeld <stefan at space dot twc dot de>
- Date: Mon, 26 Mar 2001 21:26:05 +0200
Hi!
It seems that there is some problem with assignment of anonymous unions in
recent gccs (i.e. gcc3 CVS). The following code is IMHO correct (does compile
with gcc-2.95.2), but causes problems with the CVS gcc.
stefan@stefan:/tmp$ /usr/local/gcc-2.97/bin/g++ -c au.cc
au.cc: In member function `G& G::operator=(const G&)':
au.cc:7: `G::<anonymous union>& G::<anonymous union>::operator=(const
G::<anonymous union>&)' is inaccessible
au.cc:14: within this context
Cu... Stefan
struct F {
int i;
F& operator=(const F& other) { i = other.i; }
};
struct G {
union { char c; char d; }; // if you name the union u, it will work
F f; // if you remove this line, it will work, too
};
main()
{
G g1,g2;
g1 = g2;
}
--
-* Stefan Westerfeld, stefan@space.twc.de (PGP!), Hamburg/Germany
KDE Developer, project infos at http://space.twc.de/~stefan/kde *-