public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ofekshilon at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94429] New: Bogus sequence point warning Date: Wed, 01 Apr 2020 07:35:42 +0000 [thread overview] Message-ID: <bug-94429-4@http.gcc.gnu.org/bugzilla/> (raw) 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.
next reply other threads:[~2020-04-01 7:35 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-01 7:35 ofekshilon at gmail dot com [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-94429-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).