Bug 40340 - [4.4/4.5 Regression] Fortification warning no longer emitted in inlines
Summary: [4.4/4.5 Regression] Fortification warning no longer emitted in inlines
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-04 17:33 UTC by Jakub Jelinek
Modified: 2009-06-05 16:34 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2009-06-04 17:33:20 UTC
w.h:
#pragma GCC system_header
typedef __SIZE_TYPE__ size_t;
extern void *memset (void *__s, int __c, size_t __n)
  __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
extern __inline __attribute__ ((__always_inline__))
__attribute__ ((__artificial__))
void *
__attribute__ ((__nothrow__))
memset (void *__dest, int __ch, size_t __len)
{
  return __builtin___memset_chk (__dest, __ch, __len, __builtin_object_size (__dest, 0));
}
w.c:
#include "w.h"

static inline void
test (char *p)
{
  memset (p, 0, 6);
}

int
main (void)
{
  char buf[4];
  test (buf);
  memset (buf, 0, 6);
  return 0;
}

gcc 4.3 used to emit 2 warnings, gcc 4.4 and trunk only one (but both 4.3 and 4.4+ emit two __memset_chk calls that will always __chk_fail at runtime).
Comment 1 Jakub Jelinek 2009-06-04 17:44:02 UTC
r138031 broke it altogether (no warnings were emitted at all), PR39272
made at least one of the two warnings reappear.
Comment 2 Jakub Jelinek 2009-06-04 17:55:59 UTC
4.3 reported (with -O2 -Wall):
In function 'memset',
    inlined from 'main' at w.c:6:
w.h:11: warning: call to __builtin___memset_chk will always overflow destination buffer
In function 'memset',
    inlined from 'main' at w.c:14:
w.h:11: warning: call to __builtin___memset_chk will always overflow destination buffer
4.4 reports:
In file included from w.c:1:
w.h: In function 'main':
w.h:11: warning: call to __builtin___memset_chk will always overflow destination buffer
and with -O2 -Wall -Wsystem-headers:
In file included from w.c:1:
w.h: In function 'main':
w.h:11: warning: call to __builtin___memset_chk will always overflow destination buffer
w.h:11: warning: call to __builtin___memset_chk will always overflow destination buffer
Comment 3 Jakub Jelinek 2009-06-05 15:35:36 UTC
Subject: Bug 40340

Author: jakub
Date: Fri Jun  5 15:35:13 2009
New Revision: 148212

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148212
Log:
	PR middle-end/40340
	* tree-ssa-live.c (remove_unused_scope_block_p): Don't prune
	inlined_function_outer_scope_p blocks for artificial inlines
	even at -g0/-g1.
	* tree.c (tree_nonartificial_location): Rewrite using
	block_nonartificial_location.

	* gcc.dg/pr40340-1.c: New test.
	* gcc.dg/pr40340-2.c: New test.
	* gcc.dg/pr40340-3.c: New test.
	* gcc.dg/pr40340-4.c: New test.
	* gcc.dg/pr40340-5.c: New test.
	* gcc.dg/pr40340.h: New file.

Added:
    trunk/gcc/testsuite/gcc.dg/pr40340-1.c
    trunk/gcc/testsuite/gcc.dg/pr40340-2.c
    trunk/gcc/testsuite/gcc.dg/pr40340-3.c
    trunk/gcc/testsuite/gcc.dg/pr40340-4.c
    trunk/gcc/testsuite/gcc.dg/pr40340-5.c
    trunk/gcc/testsuite/gcc.dg/pr40340.h
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-live.c
    trunk/gcc/tree.c

Comment 4 Jakub Jelinek 2009-06-05 16:32:42 UTC
Subject: Bug 40340

Author: jakub
Date: Fri Jun  5 16:31:44 2009
New Revision: 148214

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148214
Log:
	PR middle-end/40340
	* tree-ssa-live.c (remove_unused_scope_block_p): Don't prune
	inlined_function_outer_scope_p blocks for artificial inlines
	even at -g0/-g1.
	* tree.c (tree_nonartificial_location): Rewrite using
	block_nonartificial_location.

	* gcc.dg/pr40340-1.c: New test.
	* gcc.dg/pr40340-2.c: New test.
	* gcc.dg/pr40340-3.c: New test.
	* gcc.dg/pr40340-4.c: New test.
	* gcc.dg/pr40340-5.c: New test.
	* gcc.dg/pr40340.h: New file.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr40340-1.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr40340-2.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr40340-3.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr40340-4.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr40340-5.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr40340.h
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_4-branch/gcc/tree-ssa-live.c
    branches/gcc-4_4-branch/gcc/tree.c

Comment 5 Jakub Jelinek 2009-06-05 16:32:58 UTC
Subject: Bug 40340

Author: jakub
Date: Fri Jun  5 16:32:21 2009
New Revision: 148215

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148215
Log:
Fix up ChangeLog entries for
	PR middle-end/40340

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog

Comment 6 Jakub Jelinek 2009-06-05 16:34:12 UTC
Fixed.