public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pnarsing at mathworks dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101508] New: Possible undefined behaviour in cpp program using "unsigned" type starting from GCC 9 Date: Mon, 19 Jul 2021 10:25:19 +0000 [thread overview] Message-ID: <bug-101508-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101508 Bug ID: 101508 Summary: Possible undefined behaviour in cpp program using "unsigned" type starting from GCC 9 Product: gcc Version: 10.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pnarsing at mathworks dot com Target Milestone: --- Hi Team, I'm observing an optimization issue while compiling with GCC 10.3 . On investigating figured that issue is reproducible in GCC 9 as well . This can be reproduced by simple test code mentioned below : ------------------------------------------------------ using int_type = unsigned int; // works without "unsigned" int_type constexpr start{0}; // works if >= 1 int_type constexpr stop{3}; // works if <= 2 int_type constexpr mult{2}; // works if != 2 int main() { int result = 0; for(int_type aa = start; aa < stop; ++aa) { int_type const bb = aa * mult; // works if volatile if (aa > bb) { return 99; } ++result; } return result; // should be == stop } ---------------------------------------------------------------- This code snippet returns 99 instead of 3 . You can check the following link to see the issue reproducibility: https://godbolt.org/z/zd79PPKfn Modifying compiler option to -O1 and -Og avoids the issue.
next reply other threads:[~2021-07-19 10:25 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-19 10:25 pnarsing at mathworks dot com [this message] 2021-07-19 10:46 ` [Bug tree-optimization/101508] [9/10/11/12 Regression] Possible undefined behaviour in cpp program using "unsigned" type starting with r9-4145 jakub at gcc dot gnu.org 2021-07-19 11:00 ` rguenth at gcc dot gnu.org 2022-01-17 14:02 ` rguenth at gcc dot gnu.org 2022-01-24 12:15 ` cvs-commit at gcc dot gnu.org 2022-01-24 12:44 ` [Bug tree-optimization/101508] [9/10/11 " rguenth at gcc dot gnu.org 2022-01-24 12:46 ` rguenth 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-101508-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).