public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94429] New: Bogus sequence point warning
@ 2020-04-01  7:35 ofekshilon at gmail dot com
  2020-04-01 20:48 ` [Bug c++/94429] " pinskia at gcc dot gnu.org
  2020-04-01 23:29 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: ofekshilon at gmail dot com @ 2020-04-01  7:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94429

            Bug ID: 94429
           Summary: Bogus sequence point warning
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ofekshilon at gmail dot com
  Target Milestone: ---

This code:
int main() 
{
  int a = 1;
  a = ++a ;
}

built with -std=c++17 -Wall  (or just -Wsequence-point)
gives: 
<source>:4:5: warning: operation on 'a' may be undefined [-Wsequence-point]
    4 |   a = ++a ;
      |   ~~^~~~~

Since c++17 this is no longer undefined:
https://timsong-cpp.github.io/cppwp/n4659/expr.ass#1

Moreover, it seems that sometime ago the gcc team was aware of it:
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wsequence-point

"The C++17 standard will define the order of evaluation of operands in more
cases: in particular it requires that the right-hand side of an assignment be
evaluated before the left-hand side, so the above examples are no longer
undefined. But this option will still warn about them, to help people avoid
writing code that is undefined in C and earlier revisions of C++."

I (and others,
https://stackoverflow.com/questions/60937761/sequence-points-is-this-gcc-warning-a-bug)
consider this definitely a bug.  When I'm writing in C++17 and need to produce
warning-free code, I don't expect to work around the compiler saying I should
write code that would be valid in other language versions.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-01 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01  7:35 [Bug c++/94429] New: Bogus sequence point warning ofekshilon at gmail dot com
2020-04-01 20:48 ` [Bug c++/94429] " pinskia at gcc dot gnu.org
2020-04-01 23:29 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).