http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55584
Bug #: 55584 Summary: __sync_fetch_and_* friends do not issue warnings when CPU does not support them natively Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: trivial Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: rsa...@gmail.com Section 6.5.1 of the GCC 4.7.2 manual states: "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. ..." -http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc.pdf However, I cannot get this warning to be generated. I added -Wall and -Wextra. I opened the vanilla source code for 4.7.2, but the only related warning I could find was -Wsync-nand ( which warns about how the __sync*nand* functions changed their meanings with 4.4 ). The command line is: gcc test_sync_on_old_platforms.c -c -W -Wall -Wextra -m32 -march=i386 And it returns without error and emits a valid .o file. If I add the '-S' flag to GCC, the output assembly lists a call to __sync_fetch_and_add_4, as the i386 does not support atomic operations. This much is correct, but it would be good to warn when this is happening. The platform is: rsaxvc@slashtop:~/code$ gcc --version gcc (Debian 4.7.2-4) 4.7.2 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. rsaxvc@slashtop:~/code/gccbug$ uname -a Linux slashtop 3.2.0-4-amd64 #1 SMP Debian 3.2.32-1 x86_64 GNU/Linux rsaxvc@slashtop:~/code$ Similar behaviour is seen on OpenBSD/Sparc32. Here is the input code: rsaxvc@slashtop:~/code$ cat test_sync_on_old_platforms.c static unsigned int the_count; unsigned int test_sync_increment( void ) { return __sync_fetch_and_add( &the_count, 1 ); } rsaxvc@slashtop:~/code$