Bug 39272 - [4.4 Regression] -D_FORTIFY_SOURCE=2 no longer warns with new glibc headers
Summary: [4.4 Regression] -D_FORTIFY_SOURCE=2 no longer warns with new glibc headers
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Richard Biener
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2009-02-23 14:31 UTC by Richard Biener
Modified: 2009-03-03 13:06 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-02-24 09:40:46


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2009-02-23 14:31:42 UTC
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).
Comment 1 Richard Biener 2009-02-24 09:40:46 UTC
I have a semi-working patch.
Comment 2 Richard Biener 2009-03-03 13:06:05 UTC
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

Comment 3 Richard Biener 2009-03-03 13:06:11 UTC
Fixed.