C++17 std::launder and aliasing
Jakub Jelinek
jakub@redhat.com
Mon Oct 24 08:19:00 GMT 2016
On Mon, Oct 24, 2016 at 11:13:04AM +0300, Ville Voutilainen wrote:
> On 24 October 2016 at 10:41, Richard Biener <rguenther@suse.de> wrote:
> >> Seems that testcase is devirtualization related.
> >> With -O3 -fno-devirtualize we return 3 (but still no calls).
> >> With asm ("" : "+g" (p)); before return p; in launder we don't devirtualize
> >> it any more and return 3 in the end. Is the testcase only valid
> >> with std::launder and not valid otherwise (I hope so, otherwise we are in
> >> big trouble with devirtualization)?
> >
> > I believe the testcase shows a bug in devirtualization. (stpuid
> > godbolt.org having no way to textually extract the source easily)
> >
> > Please file a GCC bugreport. GCC shouldn't miscompile this even
> > without std::launder.
>
> Note that A::f() can be in a different translation unit, so we still
> need the optimization
> barrier in some cases, even if in this particular case as written we wouldn't.
And I'm afraid just conservatively assuming any method call could change
the object on which it has been called on into something different would
pretty much kill most of the devirtualization.
CCing Honza.
Jakub
More information about the Libstdc++
mailing list