Where is __builtin_launder?

Hi,

I'm trying to use __builtin_launder with Clang 6 RC2, but it doesn't seem to be available. I'm on Windows, but Wandbox's Clang HEAD doesn't seem to have this builtin either.

Am I doing something wrong, or is the builtin actually missing?

C:\Temp>type meow.cpp
#include <stdio.h>

int main() {
#ifdef __has_builtin
    #define PRINT(X) printf(#X " is %d\n", X)
    PRINT(__has_builtin(__builtin_meow));
    PRINT(__has_builtin(__builtin_huge_val));
    PRINT(__has_builtin(__builtin_launder));
#else
    puts("__has_builtin is NOT available.");
#endif

#ifdef USE_LAUNDER
    int * p = nullptr;
    int * q = __builtin_launder(p);
    (void) q;
#endif
}

C:\Temp>cl /EHsc /nologo /W4 /std:c++latest meow.cpp && meow
meow.cpp
__has_builtin is NOT available.

C:\Temp>clang-cl -v
clang version 6.0.0 (tags/RELEASE_600/rc2)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: S:\msvc\src\vctools\NonShip\ClangLLVM\bin

C:\Temp>clang-cl -m32 /EHsc /nologo /W4 /std:c++latest meow.cpp && meow
__has_builtin(__builtin_meow) is 0
__has_builtin(__builtin_huge_val) is 1
__has_builtin(__builtin_launder) is 0

C:\Temp>clang-cl -m32 /EHsc /nologo /W4 /std:c++latest /DUSE_LAUNDER meow.cpp && meow
meow.cpp(15,15): error: use of undeclared identifier '__builtin_launder'
    int * q = __builtin_launder(p);
              ^
1 error generated.

Thanks,
STL

Hi,

I'm trying to use __builtin_launder with Clang 6 RC2, but it doesn't seem to be available. I'm on Windows, but Wandbox's Clang HEAD doesn't seem to have this builtin either.

Am I doing something wrong, or is the builtin actually missing?

The patch implementing it literally hasn't been committed to Clang trunk yet. I'm not sure how you got the impression it was available for use.

John.

[STL]

Am I doing something wrong, or is the builtin actually missing?

[John McCall]

The patch implementing it literally hasn't been committed to Clang trunk yet.
I'm not sure how you got the impression it was available for use.

Aha, thanks! I was confused because libc++ marked std::launder() as "Complete, 6.0" at https://libcxx.llvm.org/cxx1z_status.html .

STL

That's an interesting choice on their part.

John.