This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82609] New: missing -Warrray-bounds on an argument in parentheses
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 18 Oct 2017 18:08:41 +0000
- Subject: [Bug c++/82609] New: missing -Warrray-bounds on an argument in parentheses
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82609
Bug ID: 82609
Summary: missing -Warrray-bounds on an argument in parentheses
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
While testing my C/C++ patch for pr82588 I noticed the following rather bizarre
bug where a -Warray-bound warning for an out-of-bounds index is suppressed by
enclosing the invalid array reference in parentheses.
$ cat a.c && gcc -O2 -S -Wall -Warray-bounds -Wextra -xc++ a.c
extern char a[2];
extern char b[2];
int f (void)
{
return a[-1]; // -Warray-bounds (good)
}
int g (void)
{
return (b[-1]); // missing -Warray-bounds in C++ only
}
a.c: In function ‘int f()’:
a.c:6:14: warning: array subscript is below array bounds [-Warray-bounds]
return a[-1]; // -Warray-bounds (good)
~~~~^