https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65083
Bug ID: 65083 Summary: Can not indirectly call some C11 atomic library functions Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: bin.x.fan at oracle dot com C11 defines these as actual functions, not generic functions or macros: atomic_thread_fence atomic_signal_fence atomic_flag_test_and_set atomic_flag_test_and_set_explicit atomic_flag_clear atomic_flag_clear_explicit User should be able to take their address and call them indirectly. However, GCC does not provide definitions of these functions in libatomic.so, so GCC does not allow the user to take the address of these functions. Here is an example: -bash-4.1$ gcc -v Using built-in specs. COLLECT_GCC=/net/dv104/export/tools/gcc/4.9.2/sparc-S2/bin/gcc.bin COLLECT_LTO_WRAPPER=/net/dv104/export/tools/gcc/4.9.2/sparc-S2/libexec/gcc/sparc-sun-solaris2.10/4.9.2/lto-wrapper Target: sparc-sun-solaris2.10 Configured with: ../gcc-4.9.2/configure --prefix=/net/dv104/export/tools/gcc/4.9.2/sparc-S2 --enable-languages=c,c++,fortran --with-gmp=/net/dv104/export/tools/gcc/4.9.2/sparc-S2 --with-mpfr=/net/dv104/export/tools/gcc/4.9.2/sparc-S2 --with-mpc=/net/dv104/export/tools/gcc/4.9.2/sparc-S2 Thread model: posix gcc version 4.9.2 (GCC) -bash-4.1$ cat t.c #include <stdatomic.h> void (*func_ptr) (memory_order order); int main() { func_ptr = &atomic_thread_fence; (*func_ptr)(memory_order_seq_cst); return 0; } -bash-4.1$ gcc t.c -latomic t.c: In function 'main': t.c:5:15: error: 'atomic_thread_fence' undeclared (first use in this function) func_ptr = &atomic_thread_fence; ^ t.c:5:15: note: each undeclared identifier is reported only once for each function it appears in