This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81475] missing -Wsequence-point on a self-referential array access


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
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]