C++17 std::launder and aliasing

Richard Biener rguenther@suse.de
Mon Oct 24 12:11:00 GMT 2016


On Mon, 24 Oct 2016, Jakub Jelinek wrote:

> On Mon, Oct 24, 2016 at 02:01:12PM +0200, Richard Biener wrote:
> > Ok, so with two std::launder (&a) and launder being CONST we'd happily
> > CSE them.  Which means repeatedly laundering &a wouldn't work.  You'd
> > have to do
> > 
> >   A *p = std::launder (&a)->g();
> >   A *q = std::launder(p)->f();
> >   std::launder (q)->g();
> > ...
> 
> I agree CSEing std::launder is undesirable, not in the testcase I've posted,
> there it is just fine, but in others.  So I'll test with ECF_LEAF | ECF_NOTHROW.

OTOH if we have to use the result of launder to access the laundered 
object we can DCE launder and also optimize launder(launder(&a)) to
launder(&a).

Thus if you continue with making it work semantically by pessimizing
the points-to for the result you can use ECF_NOVOPS (otherwise you
have to play tricks with DCE and pattern matching launder(launder())
gets interesting due to vops).

Richard.



More information about the Libstdc++ mailing list