[Bug tree-optimization/83412] New: GCC line directive suppresses warnings
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 13 17:23:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83412
Bug ID: 83412
Summary: GCC line directive suppresses warnings
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
For some reason the GCC # line directive suppresses warnings. See bug 83404,
comment 2 for the origin of this bug report.
$ cat a.c && gcc -O2 -S -Wall a.c
#include <string.h>
char x[12];
void f (void)
{
__builtin_strncat (x, "aa", 1); // warning (good)
}
void g (void)
{
strncat (x, "aa", 1); // no warning (bug)
}
a.c: In function ‘f’:
a.c:7:3: warning: ‘__builtin_strncat’ output truncated copying 1 byte from a
string of length 2 [-Wstringop-truncation]
__builtin_strncat (x, "aa", 1); // warning (good)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The problem can be reproduced with another, simpler test case:
$ cat a.ii && gcc -O2 -S -Wall a.ii
char x[12];
void f (void)
{
x[13] = 0; // -Warray-bounds (good)
}
int g (void)
{
# 12 "a.c" 3 4
return x[13]; // no warning (bug)
}
a.ii: In function ‘void f()’:
a.ii:5:7: warning: array subscript 13 is above array bounds of ‘char [12]’
[-Warray-bounds]
x[13] = 0; // -Warray-bounds (good)
~~~~^
More information about the Gcc-bugs
mailing list