GCC 4.3 prints an unsuppressable warning about any use of a static inline function or static const data in a non-static inline function.
While this is useful for non-const static data, and possibly for non-inlined static functions, it is extremely annoying for static inline functions or static const objects. On MacOS X Leopard (Darwin 9), the following program prints warnings. (Note that htons() has a static inline declaration in the system header files. This problem makes extern inline functions essentially useless, since they cannot use system inline functions without warnings.) #include <arpa/inet.h> #include <stdbool.h> extern inline short ntohs_wrapper(short x) { return ntohs(x); } extern inline bool less_than_threshhold(int val) { static const int threshhold = 100; return val < threshhold; } [EMAIL PROTECTED] ~]$ ~/FSF-GCC/bin/gcc -c inline-test.c inline-test.c: In function 'ntohs_wrapper': inline-test.c:6: warning: '_OSSwapInt16' is static but used in inline function 'ntohs_wrapper' which is not static inline-test.c: In function 'less_than_threshhold': inline-test.c:12: warning: 'threshhold' is static but declared in inline function 'less_than_threshhold' which is not static inline-test.c:13: warning: 'threshhold' is static but used in inline function 'less_than_threshhold' which is not static [EMAIL PROTECTED] ~]$ ~/FSF-GCC/bin/gcc -c -v inline-test.c Using built-in specs. Target: i386-apple-darwin9.0.0 Configured with: ../gcc/configure --prefix=/Users/jonathan/FSF-GCC/ --with-gmp=/Users/jonathan/FSF-GCC/ --with-mpfr=/Users/jonathan/FSF-GCC/ --enable-lanaguages=c,c++,fortran,objc,obj-c++ --enable-checking=release --with-tune=generic Thread model: posix gcc version 4.3.0 20071105 (experimental) (GCC) COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.5.0' '-c' '-v' '-mtune=generic' /Users/jonathan/FSF-GCC/bin/../libexec/gcc/i386-apple-darwin9.0.0/4.3.0/cc1 -quiet -v -iprefix /Users/jonathan/FSF-GCC/bin/../lib/gcc/i386-apple-darwin9.0.0/4.3.0/ -D__DYNAMIC__ inline-test.c -fPIC -quiet -dumpbase inline-test.c -mmacosx-version-min=10.5.0 -mtune=generic -auxbase inline-test -version -o /var/tmp//ccJzAq19.s ignoring nonexistent directory "/Users/jonathan/FSF-GCC/bin/../lib/gcc/i386-apple-darwin9.0.0/4.3.0/../../../../i386-apple-darwin9.0.0/include" ignoring nonexistent directory "/usr/local/include" ignoring duplicate directory "/Users/jonathan/FSF-GCC/bin/../lib/gcc/../../lib/gcc/i386-apple-darwin9.0.0/4.3.0/include" ignoring duplicate directory "/Users/jonathan/FSF-GCC/bin/../lib/gcc/../../lib/gcc/i386-apple-darwin9.0.0/4.3.0/include-fixed" ignoring nonexistent directory "/Users/jonathan/FSF-GCC/bin/../lib/gcc/../../lib/gcc/i386-apple-darwin9.0.0/4.3.0/../../../../i386-apple-darwin9.0.0/include" #include "..." search starts here: #include <...> search starts here: /Users/jonathan/FSF-GCC/bin/../lib/gcc/i386-apple-darwin9.0.0/4.3.0/include /Users/jonathan/FSF-GCC/bin/../lib/gcc/i386-apple-darwin9.0.0/4.3.0/include-fixed /Users/jonathan/FSF-GCC/bin/../lib/gcc/../../include /usr/include /System/Library/Frameworks /Library/Frameworks End of search list. GNU C (GCC) version 4.3.0 20071105 (experimental) (i386-apple-darwin9.0.0) compiled by GNU C version 4.3.0 20071105 (experimental), GMP version 4.2.2, MPFR version 2.3.0. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 4eaa8600939e59258d37cac385804206 inline-test.c: In function 'ntohs_wrapper': inline-test.c:6: warning: '_OSSwapInt16' is static but used in inline function 'ntohs_wrapper' which is not static inline-test.c: In function 'less_than_threshhold': inline-test.c:12: warning: 'threshhold' is static but declared in inline function 'less_than_threshhold' which is not static inline-test.c:13: warning: 'threshhold' is static but used in inline function 'less_than_threshhold' which is not static COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.5.0' '-c' '-v' '-mtune=generic' as -arch i386 -force_cpusubtype_ALL -o inline-test.o /var/tmp//ccJzAq19.s COMPILER_PATH=/Users/jonathan/FSF-GCC/bin/../libexec/gcc/i386-apple-darwin9.0.0/4.3.0/:/Users/jonathan/FSF-GCC/bin/../libexec/gcc/ LIBRARY_PATH=/Users/jonathan/FSF-GCC/bin/../lib/gcc/i386-apple-darwin9.0.0/4.3.0/:/Users/jonathan/FSF-GCC/bin/../lib/gcc/:/Users/jonathan/FSF-GCC/bin/../lib/gcc/i386-apple-darwin9.0.0/4.3.0/../../../:/usr/lib/ COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.5.0' '-c' '-v' '-mtune=generic' COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.5.0' '-c' '-v' '-mtune=generic' This problem appears to have been introduced by Geoffrey Keating in Subversion Revision 118356, a fix for PR 11377. GCC 4.2 does not have this problem. -- Summary: GCC pedwarns about use of static inline functions or static const data in extern inline functions Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: lennox at cs dot columbia dot edu GCC build triplet: i686-apple-darwin9 GCC host triplet: i686-apple-darwin9 GCC target triplet: i686-apple-darwin9 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34000