C++17 std::launder and aliasing

Ville Voutilainen ville.voutilainen@gmail.com
Mon Oct 24 08:13:00 GMT 2016


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.



More information about the Libstdc++ mailing list