http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52755

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-28 
17:39:52 UTC ---
(In reply to comment #0)
> Following code compiles fine with every gcc, with every g++ -std=c++98, 
> with g++-4.5 -std=c++0x, but not with g++ -std=c++0x (or -std=c++11) since 
> 4.6.

That's because G++ 4.6 was changed to reject your invalid program, it's
supposed to do that, and it means G++ 4.6 is better than G++ 4.5 :)

Isn't the error quite clear?

Assigning t2s needs to use the assignment operator, but that function can't be
implicitly-defined because assigning the volatile member requires
t1s::operator=(const volatile t1s&) which doesn't exist, because the
implicit-declared copy assignment operator has the signature
t1s::operator=(const t1s&)

To fix your code you should either define copy assignment for t1s so it works
on volatile objects, or define assignment for t2s so it doesn't need
t1s::operator= e.g.

  t2s& operator=(const t2s& t) { b.a = t.b.a; return *this; }

Reply via email to