llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

__builtin_setjmp is not compatible with GCC

Open llvmbot opened this issue 14 years ago • 1 comments

Bugzilla Link 13918
Resolution FIXED
Resolved on Oct 16, 2012 11:18
Version trunk
OS Linux
Attachments Test case
Reporter LLVM Bugzilla Contributor
CC @darkbuck

Extended Description

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 resume address that is used to longjmp back.

A test case is attached, based on the below test from GCC http://gcc.gnu.org/viewcvs/trunk/gcc/testsuite/gcc.c-torture/execute/built-in-setjmp.c?revision=184997&view=markup

When compiled using GCC 4.6.3 (gcc __builtin_setjmp-test.c) the test program returns 1, as expected.

When compiled using Clang 3.2 (clang __builtin_setjmp-test.c) the test program segfaults.

Since the __builtin_setjmp function is supposed to be compatible with GCC, this is a problem.

llvmbot avatar Sep 25 '12 20:09 llvmbot

fixed in r165989 for X86 backend.

darkbuck avatar Oct 16 '12 18:10 darkbuck