This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Anonymous union assignment problem


   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 *-         


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]