Linking fails for the program below, with the error: undefined reference to `___sync_val_compare_and_swap_4'
// gcc -Wall atomic.c int main() { int *a, b, c; return __sync_val_compare_and_swap(a, b, c); } According to the atomic builtins docs (), "Not all operations are supported by all target processors. If a particular operation cannot be implemented on the target processor, a warning will be generated and a call an external function will be generated. The external function will carry the same name as the builtin, with an additional suffix `_n' where n is the size of the data type." If CAS is not supported, how come I don't get a warning? Why would i686 *not* support compare and swap? The cmpxchg instruction has been around since 80486, according to the intel IA-32 processor manual. Also, does an unsupported builtin mean the user is responsible to write that function, or simply that the compiler must make a function call to synthesize its behavior? FWIW, my x86_64 cross-compile gcc 4.2.0 handles it fine, emitting a "lock"+"cmpxchg" pair. -- Summary: atomic builtins not supported on i686? Product: gcc Version: 4.2.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: scovich at gmail dot com GCC host triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34115