public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mikpelinux at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/64294] invalid code, zero check gets optimized away Date: Sat, 20 Dec 2014 15:24:00 -0000 [thread overview] Message-ID: <bug-64294-4-Yc8k4cetil@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-64294-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64294 --- Comment #10 from Mikael Pettersson <mikpelinux at gmail dot com> --- You're invoking undefined behaviour due to overflow in signed integer arithmetic. Running it after compiling with -fsanitize=undefined produces: petite.c:391:28: runtime error: signed integer overflow: 2147483647 * 2 cannot be represented in type 'int' Fixing that in the following crude way: --- petite.c 2014-12-20 16:02:59.786063515 +0100 +++ petite-fixed.c 2014-12-20 16:15:05.030889115 +0100 @@ -388,7 +388,7 @@ free(usects); return 1; } - backbytes = backbytes*2 + oob; + backbytes = (int)((unsigned int)backbytes*2 + (unsigned int)oob); if ( (oob = doubledl(&ssrc, &mydl, buf, bufsz)) == -1 ) { free(usects); return 1; allows the testcase to work at -O2 and -O3.
next prev parent reply other threads:[~2014-12-20 15:24 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-12-12 22:25 [Bug rtl-optimization/64294] New: " gcc at breakpoint dot cc 2014-12-12 22:43 ` [Bug rtl-optimization/64294] " schwab@linux-m68k.org 2014-12-12 22:54 ` gcc at breakpoint dot cc 2014-12-13 20:58 ` gcc at breakpoint dot cc 2014-12-13 20:59 ` gcc at breakpoint dot cc 2014-12-13 21:12 ` gcc at breakpoint dot cc 2014-12-20 11:53 ` mikpelinux at gmail dot com 2014-12-20 14:30 ` gcc at breakpoint dot cc 2014-12-20 14:35 ` gcc at breakpoint dot cc 2014-12-20 15:24 ` mikpelinux at gmail dot com [this message] 2014-12-20 21:21 ` gcc at breakpoint dot cc
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-64294-4-Yc8k4cetil@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).