[cfe-dev] Where is __builtin_launder?

John McCall via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 22 21:14:13 PST 2018


> On Feb 22, 2018, at 11:52 PM, Stephan T. Lavavej via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> 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.

> 
> 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
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list