https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82899

--- Comment #8 from Antony Polukhin <antoshkka at gmail dot com> ---
(In reply to Richard Biener from comment #4)
> (In reply to Antony Polukhin from comment #2)
> > Looks like [class.ctor] paragraph 14 covers this case:
> > 
> > "During the construction of an object, if the value of the object or any of
> > its subobjects is accessed through
> > a glvalue that is not obtained, directly or indirectly, from the
> > constructor’s this pointer, the value of the
> > object or subobject thus obtained is unspecified."
> 
> Yeah, sounds like covering this case.  Thus we can make 'this' restrict in
> constructors (and possibly assignment operators if self-assignment is
> forbidden).

Self assignment is tricky and is OK to alias in most cases. It could be
restricted at some point after the `this != &rhs` check (as proposed in Bug
82918). 

I'd rather start by "restricting this" for copy and move constructors, leaving
assignment as is.

Reply via email to