[cfe-dev] Where is __builtin_launder?

Stephan T. Lavavej via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 22 20:52:18 PST 2018


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



More information about the cfe-dev mailing list