From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17663 invoked by alias); 9 Dec 2008 15:43:36 -0000 Received: (qmail 17121 invoked by uid 48); 9 Dec 2008 15:42:11 -0000 Date: Tue, 09 Dec 2008 15:43:00 -0000 Subject: [Bug middle-end/38454] New: [4.4 Regression] memcpy folding breaks -D_FORTIFY_SOURCE=2 protection X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jakub at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-12/txt/msg00832.txt.bz2 /* { dg-do compile } */ /* { dg-options "-O2" } */ typedef __SIZE_TYPE__ size_t; extern inline __attribute__((gnu_inline, always_inline, artificial)) void * memcpy (void *__restrict dest, const void *__restrict src, size_t len) { return __builtin___memcpy_chk (dest, /* { dg-warning "will always overflow destination buffer" } */ src, len, __builtin_object_size (dest, 0)); } struct S { char buf[10]; } s; void foo (void) { char buf[12]; char *p = buf + 4; struct S *q = (struct S *) p; memcpy (q, &s, sizeof (s)); } /* { dg-final { scan-assembler "__memcpy_chk" } } */ FAILs since I've added new memcpy folding. The memcpy is folded before it is inlined and so it isn't warned on, nor checked at runtime. Testing a patch that will help this as well as e.g. the memset swapped arguments warning. -- Summary: [4.4 Regression] memcpy folding breaks - D_FORTIFY_SOURCE=2 protection Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: jakub at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38454