std::launder was introduced into c++17 as a compiler optimization barrier. It's something that the compiler 'knows about', and affects codegen.
See https://wg21.link/p0137r1 for more.
Differential D40144
Implement `std::launder` mclow.lists on Nov 16 2017, 11:50 AM. Authored by
Details std::launder was introduced into c++17 as a compiler optimization barrier. It's something that the compiler 'knows about', and affects codegen. See https://wg21.link/p0137r1 for more.
Diff Detail Event Timeline
Comment Actions At least for GCC, it should use __builtin_launder. Also needs to implement "The program is ill-formed if T is a function type or cv void." Comment Actions I presume we'll need to add something similar for Clang as well.
Comment Actions Yes, we agreed to use the same builtin name for this in Clang and GCC quite a while back, but haven't actually got around to implementing it in Clang yet. You should use __has_builtin to detect the existence of this builtin in Clang. In GCC, I believe this is available iff __GNUC__ is 7 or greater.
Comment Actions Move the launder function into the main libc++ namespace. Comment Actions I think we may want a __launder function that we can use internally in all dialects.
Comment Actions Made an internal function __launder which is not c++17 specific.
|
These macros should take the negative _LIBCPP_HAS_NO_BUILTIN_LAUNDER form to be consistent.