When __sync_fetch_and_xxx builtin functions are required to store the return value the compiler generates an undefined reference during the link stage.
void main( void ) { long a=0; #ifndef SHOW_BUG __sync_fetch_and_add(&a,1); /* works just fine */ #else a=__sync_fetch_and_add(&a,1); /* creates an undefined symbol */ #endif } -- Summary: __sync_fetch_and_xxx generates relocatable symbols Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: timothy dot krause at shaw dot ca http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37509