[Bug c++/81475] missing -Wsequence-point on a self-referential array access
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Feb 1 21:40:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81475
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-02-01
CC| |msebor at gcc dot gnu.org
Summary|Missing "undefined |missing -Wsequence-point on
|behavior" warning |a self-referential array
| |access
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
You can download draft revisions of the C++ standard from the ISO/IEC WG21 C++
site: http://www.open-std.org/jtc1/sc22/wg21
But please keep in mind this is not the right place to ask for language
reference manuals.
That said, I can confirm that the test case has undefined behavior and should
trigger a -Wsequence-point warning. Here's a smaller C/C++ test case the
demonstrates the same limitation.
No GCC release diagnosed this code so this is not a regression.
int f (void)
{
int ar[2], *a = ar;
a[0] = 1;
return a[(*a)++ - 1]; // missing -Wsequence-point
}
More information about the Gcc-bugs
mailing list