__builtin_setjmp compatability with gcc


I’ve noticed that the __builtin_setjmp function does different things on Clang compared to GCC. On Clang only the stack pointer and frame pointer are saved, while GCC also saves the address that is used to longjmp back. This is causing problems (segfaults) with code compiled using Clang that links with a library built with GCC.

The file /include/clang/Basic/Builtins.def seems to imply that they should be compatible, as __buildin_setjmp is listed under the header “Random GCC Builtins”.

Is this a bug with Clang or the intended behavior?


Stuart Rudderham

Sounds like a bug; __builtin_setjmp is supposed to be gcc-compatible,
although I don't think it gets much testing.


Thanks for the reply. I've filed a bug report here -> http://llvm.org/bugs/show_bug.cgi?id=13918.

- Stuart Rudderham