t.h: #pragma GCC system_header extern __inline __attribute__ ((__always_inline__)) char * __attribute__ ((__nothrow__)) blabla (char *__restrict __dest, __const char *__restrict __src) { return __builtin___strcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1)); } t.c: #include "t.h" char buf[6]; int main(int argc, char **argv) { blabla(buf,"hello "); return 0; } no longer warns with GCC 4.4 because blabla is in a system-header (blabla == strcpy, but 4.3 folds that to memcpy which we also do not warn, 4.4 doesn't do that folding).
I have a semi-working patch.
Subject: Bug 39272 Author: rguenth Date: Tue Mar 3 13:05:53 2009 New Revision: 144573 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144573 Log: 2009-03-03 Richard Guenther <rguenther@suse.de> PR middle-end/39272 * tree.c (tree_nonartificial_location): New function. * tree.h (tree_nonartificial_location): Declare. * builtins.c (expand_builtin_memory_chk): Provide location of the call location for artificial function pieces. (maybe_emit_chk_warning): Likewise. (maybe_emit_sprintf_chk_warning): Likewise. (maybe_emit_free_warning): Likewise. * expr.c (expand_expr_real_1): Likewise. Modified: trunk/gcc/ChangeLog trunk/gcc/builtins.c trunk/gcc/expr.c trunk/gcc/tree.c trunk/gcc/tree.h
Fixed.