[Bug middle-end/80020] New: gcc confused about aligned_alloc argument order
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Mar 12 21:56:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80020
Bug ID: 80020
Summary: gcc confused about aligned_alloc argument order
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
>From https://bugzilla.redhat.com/show_bug.cgi?id=1431367. Attribute alloc_size
added to __builtin_aligned_alloc in builtins.def in r243470 specifies argument
1 when the correct argument is actually 2. This causes -Wstringop-overflow=
false positives and negatives, and with _FORTIFY_SOURCE, leads to aborts at
runtime.
$ cat u.c && gcc -O2 -S -Wall -Wextra -Wpedantic u.c
char d[7];
void f (void)
{
unsigned size = 16;
void *p = __builtin_aligned_alloc (4, size);
__builtin___memset_chk (p, 0, size, __builtin_object_size (p, 0));
}
u.c: In function ‘f’:
u.c:7:3: warning: ‘__builtin___memset_chk’ writing 16 bytes into a region of
size 4 overflows the destination [-Wstringop-overflow=]
__builtin___memset_chk (p, 0, size, __builtin_object_size (p, 0));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the Gcc-bugs
mailing list