[Bug middle-end/61158] negative shift at fold-const.c:12095
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61158 Vittorio Zecca changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #10 from Vittorio Zecca --- Resolved.
[Bug middle-end/61158] negative shift at fold-const.c:12095
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61158 John David Anglin danglin at gcc dot gnu.org changed: What|Removed |Added CC||danglin at gcc dot gnu.org --- Comment #8 from John David Anglin danglin at gcc dot gnu.org --- gcc.dg/pr61158.c fails on hppa2.0w-hp-hpux11.11 on 4.9 branch: spawn /mnt/gnu/gcc/objdir-test/gcc/xgcc -B/mnt/gnu/gcc/objdir-test/gcc/ /mnt/gnu /gcc/gcc/gcc/testsuite/gcc.dg/pr61158.c -fno-diagnostics-show-caret -fdiagnostic s-color=never -O2 -fdump-tree-original -S -o pr61158.s PASS: gcc.dg/pr61158.c (test for excess errors) FAIL: gcc.dg/pr61158.c scan-tree-dump original return 0; This is tree dump: # less pr61158.c.003t.original ;; Function foo (null) ;; enabled by -tree-original { return ((long long unsigned int) x 71776119061217280) 40; }
[Bug middle-end/61158] negative shift at fold-const.c:12095
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61158 --- Comment #9 from John David Anglin danglin at gcc dot gnu.org --- It looks like the test fails because HOST_BITS_PER_WIDE_INT is 32 on hppa2.0w-hp-hpux11.11. As a result, the fold optimization doesn't occur.
[Bug middle-end/61158] negative shift at fold-const.c:12095
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61158 --- Comment #5 from Jakub Jelinek jakub at gcc dot gnu.org --- Author: jakub Date: Thu May 15 10:01:11 2014 New Revision: 210467 URL: http://gcc.gnu.org/viewcvs?rev=210467root=gccview=rev Log: PR tree-optimization/61158 * fold-const.c (fold_binary_loc): If X is zero-extended and shiftc = prec, make sure zerobits is all ones instead of invoking undefined behavior. * gcc.dg/pr61158.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr61158.c Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog
[Bug middle-end/61158] negative shift at fold-const.c:12095
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61158 --- Comment #7 from Jakub Jelinek jakub at gcc dot gnu.org --- Author: jakub Date: Thu May 15 10:08:12 2014 New Revision: 210469 URL: http://gcc.gnu.org/viewcvs?rev=210469root=gccview=rev Log: PR tree-optimization/61158 * fold-const.c (fold_binary_loc): If X is zero-extended and shiftc = prec, make sure zerobits is all ones instead of invoking undefined behavior. * gcc.dg/pr61158.c: New test. Added: branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr61158.c Modified: branches/gcc-4_9-branch/gcc/ChangeLog branches/gcc-4_9-branch/gcc/fold-const.c branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
[Bug middle-end/61158] negative shift at fold-const.c:12095
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61158 --- Comment #6 from Jakub Jelinek jakub at gcc dot gnu.org --- Fixed for 4.9.1+ so far.
[Bug middle-end/61158] negative shift at fold-const.c:12095
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61158 --- Comment #3 from Marek Polacek mpolacek at gcc dot gnu.org --- (In reply to Vittorio Zecca from comment #2) I found this one with -fsanitize=shift. The runtime error message says shift exponent -8 is negative. Maybe this is also a sanitizer bug? Yeah, I opened PR61185.
[Bug middle-end/61158] negative shift at fold-const.c:12095
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61158 Jakub Jelinek jakub at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2014-05-14 CC||jakub at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #4 from Jakub Jelinek jakub at gcc dot gnu.org --- Created attachment 32795 -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=32795action=edit gcc49-pr61158.patch Untested fix. If prec = shiftc, then the result is always 0, as we shift away all the possibly non-zero bits. Therefore, we should just optimize it into (X, 0).
[Bug middle-end/61158] negative shift at fold-const.c:12095
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61158 Marek Polacek mpolacek at gcc dot gnu.org changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org Component|c |middle-end --- Comment #1 from Marek Polacek mpolacek at gcc dot gnu.org --- prec and shiftc are both unsigned, so it's not -8, but some huge number. That indeed looks like a bug. This code was added in r130589.
[Bug middle-end/61158] negative shift at fold-const.c:12095
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61158 --- Comment #2 from Vittorio Zecca zeccav at gmail dot com --- I found this one with -fsanitize=shift. The runtime error message says shift exponent -8 is negative. Maybe this is also a sanitizer bug?