On Mac OS X 10.6, Apple has modified their system header files to use 'static inline' functions much more extensively (I believe they're now using fortify by default?) However, GCC (since version 4.3) prints an unsuppressible pedwarn about any use of a static inline function in a non-static inline function. This essentially means that basic libc functions are unusable from non-static inline functions. Thus, on Mac OS X 10.6.6 with a current GCC tree from subversion: $ cat inline-test.c #include <string.h> extern inline __attribute__((__gnu_inline__)) void* memcpy_wrap_1(void* dst, const void* src, size_t n) { return memcpy(dst, src, n); } inline void* memcpy_wrap_2(void* dst, const void* src, size_t n) { return memcpy(dst, src, n); } void foo(char *buf1, char *buf2, char *buf3, char *buf4, size_t length) { memcpy_wrap_1(buf1, buf2, length); memcpy_wrap_2(buf3, buf4, length); } $ ~/GCC/svn/bin/gcc-4.6 -c --std=gnu99 --sysroot=/Developer/SDKs/MacOSX10.6.sdk/ inline-test.c inline-test.c:12:9: warning: ‘__inline_memcpy_chk’ is static but used in inline function ‘memcpy_wrap_2’ which is not static [enabled by default] inline-test.c:6:9: warning: ‘__inline_memcpy_chk’ is static but used in inline function ‘memcpy_wrap_1’ which is not static [enabled by default] Jonathan-Lennoxs-MacBook-Pro:scratch jonathan$ ~/GCC/svn/bin/gcc-4.6 -v -c --std=gnu99 --sysroot=/Developer/SDKs/MacOSX10.6.sdk/ inline-test.c Using built-in specs. COLLECT_GCC=/Users/jonathan/GCC/svn/bin/gcc-4.6 COLLECT_LTO_WRAPPER=/Users/jonathan/GCC/svn/libexec/gcc/x86_64-apple-darwin10.6.0/4.6.0/lto-wrapper Target: x86_64-apple-darwin10.6.0 Configured with: ../trunk/configure --prefix=/Users/jonathan/GCC/svn --with-build-config=bootstrap-lto --enable-stage1-languages=c,lto --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-checking=release --program-suffix=-4.6 Thread model: posix gcc version 4.6.0 20110218 (experimental) (GCC) COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.6.6' '-v' '-c' '-std=gnu99' '-mtune=core2' /Users/jonathan/GCC/svn/libexec/gcc/x86_64-apple-darwin10.6.0/4.6.0/cc1 -quiet -v -isysroot /Developer/SDKs/MacOSX10.6.sdk/ -D__DYNAMIC__ inline-test.c -fPIC -quiet -dumpbase inline-test.c -mmacosx-version-min=10.6.6 -mtune=core2 -auxbase inline-test -std=gnu99 -version -o /var/folders/DK/DKO9pSWtFASzzyjD7MKJl++++TI/-Tmp-//ccg3ldYs.s GNU C (GCC) version 4.6.0 20110218 (experimental) (x86_64-apple-darwin10.6.0) compiled by GNU C version 4.6.0 20110218 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/Developer/SDKs/MacOSX10.6.sdk//usr/local/include" ignoring nonexistent directory "/Users/jonathan/GCC/svn/lib/gcc/x86_64-apple-darwin10.6.0/4.6.0/../../../../x86_64-apple-darwin10.6.0/include" #include "..." search starts here: #include <...> search starts here: /Users/jonathan/GCC/svn/lib/gcc/x86_64-apple-darwin10.6.0/4.6.0/include /Users/jonathan/GCC/svn/include /Users/jonathan/GCC/svn/lib/gcc/x86_64-apple-darwin10.6.0/4.6.0/include-fixed /Developer/SDKs/MacOSX10.6.sdk//usr/include /Developer/SDKs/MacOSX10.6.sdk//System/Library/Frameworks /Developer/SDKs/MacOSX10.6.sdk//Library/Frameworks End of search list. GNU C (GCC) version 4.6.0 20110218 (experimental) (x86_64-apple-darwin10.6.0) compiled by GNU C version 4.6.0 20110218 (experimental), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 1e40ed1f0984385bdcb3920828281613 inline-test.c:12:9: warning: ‘__inline_memcpy_chk’ is static but used in inline function ‘memcpy_wrap_2’ which is not static [enabled by default] inline-test.c:6:9: warning: ‘__inline_memcpy_chk’ is static but used in inline function ‘memcpy_wrap_1’ which is not static [enabled by default] COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.6.6' '-v' '-c' '-std=gnu99' '-mtune=core2' as -arch x86_64 -force_cpusubtype_ALL -o inline-test.o /var/folders/DK/DKO9pSWtFASzzyjD7MKJl++++TI/-Tmp-//ccg3ldYs.s COMPILER_PATH=/Users/jonathan/GCC/svn/libexec/gcc/x86_64-apple-darwin10.6.0/4.6.0/:/Users/jonathan/GCC/svn/libexec/gcc/x86_64-apple-darwin10.6.0/4.6.0/:/Users/jonathan/GCC/svn/libexec/gcc/x86_64-apple-darwin10.6.0/:/Users/jonathan/GCC/svn/lib/gcc/x86_64-apple-darwin10.6.0/4.6.0/:/Users/jonathan/GCC/svn/lib/gcc/x86_64-apple-darwin10.6.0/ LIBRARY_PATH=/Users/jonathan/GCC/svn/lib/gcc/x86_64-apple-darwin10.6.0/4.6.0/:/Users/jonathan/GCC/svn/lib/gcc/x86_64-apple-darwin10.6.0/4.6.0/../../../:/Developer/SDKs/MacOSX10.6.sdk//usr/lib/ COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.6.6' '-v' '-c' '-std=gnu99' '-mtune=core2' I've reported this in some other contexts in the past: see PR 34000 and PR 42951. The solutions, as I see it, would either be to fixinclude the Mac OS X header files (a solution which doesn't work well with the Mac OS X /Developer/SDKs/ pattern of alternate build environments, and which also has problems with pointers-to-functions), or else (my preference) to suppress this warning if the static inline function that's being called is defined in a system header file. (I believe Apple's GCC does the latter.) This problem did not occur in GCC 4.2, and is thus a regression.
Can you attach preprocessed source?
Created attachment 23404 [details] Preprocessed source for test case
The Mac OS system headers don't trigger this issue anymore. The general problem is still relevant, but it's already present in PR42951, so I'm closing as a duplicate. *** This bug has been marked as a duplicate of bug 42951 ***