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

--- Comment #22 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #20)
> (In reply to Jakub Jelinek from comment #16)
> > (In reply to Richard Biener from comment #15)
> > > where if I understand you correctly, bar () is not allowed to modify *this
> > > (unless I pass it an argument to it, of course), even if *this is for
> > > example
> > 
> > Why?  Because it is a constructor and the object isn't fully constructed yet
> > at that point?
> 
> Yes, exactly. The object's lifetime has not started until the constructor
> completes, so accessing it is only allowed in very limited ways, described
> in [basic.life] p6. However, it looks like for a non-trivial constructor the
> results are just unspecified, not undefined, see [class.cdtor] p2. Still, I
> don't see how operator new could meaningfully do anything to an object under
> construction if the object is in an unspecified state. And frankly, if
> anybody did write an operator new like that, they deserve what they get.
> 
> Could we have a flag that says "assume operator new is not stupid"?

We certainly could add that and with that revert the effect of not making
new/delete "pure" (I'd have to look up the PR we've reverted the change
that generally made it so).

Reply via email to