Created attachment 40999 [details] C file to reproduce the bug When building the attached C source file with GCC 6.3.1 or GCC 5.4.0 on an x86 (32bit) system and the compiler flags '-std=c89 -fsanitize=float-divide-by-zero', an internal compiler error happens. It doesn't happen on x86_64, ppc or armv7 from what I tested. Output for GCC 5.4.0: gcc-5 -std=c89 -fsanitize=float-divide-by-zero bug.c -c bug.c: In function ‘bug’: bug.c:3:2: internal compiler error: in c_fully_fold_internal, at c-family/c-common.c:1545 int test = (1 / number >= 1); ^ Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.archlinux.org/> for instructions. make: *** [Makefile:2: bug] Error 1 Output for GCC 6.0.3: cc -std=c89 -fsanitize=float-divide-by-zero bug.c -c bug.c: In function ‘bug’: bug.c:3:2: internal compiler error: in c_fully_fold_internal, at c/c-fold.c:558 int test = (1 / number >= 1); ^~~ Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.archlinux.org/> for instructions. make: *** [Makefile:2: bug] Error 1
Created attachment 41000 [details] Makefile with the compiler options necessary to reproduce the bug
I already created a bug report in the Archlinux bug tracker here: https://bugs.archlinux.org/task/53368 but I could also reproduce the bug on Ubuntu 16.04.2 with GCC 5.4.0
Looking into this.
Created attachment 41002 [details] gcc7-pr80097.patch Untested fix.
Author: jakub Date: Tue Mar 21 07:01:05 2017 New Revision: 246302 URL: https://gcc.gnu.org/viewcvs?rev=246302&root=gcc&view=rev Log: PR c/80097 * c-typeck.c (build_binary_op): Add EXCESS_PRECISION_EXPR only around optional COMPOUND_EXPR with ubsan instrumentation. * gcc.dg/ubsan/pr80097.c: New test. Added: trunk/gcc/testsuite/gcc.dg/ubsan/pr80097.c Modified: trunk/gcc/c/ChangeLog trunk/gcc/c/c-typeck.c trunk/gcc/testsuite/ChangeLog
Fixed on the trunk so far.
Author: jakub Date: Fri May 5 21:42:05 2017 New Revision: 247687 URL: https://gcc.gnu.org/viewcvs?rev=247687&root=gcc&view=rev Log: Backported from mainline 2017-03-21 Jakub Jelinek <jakub@redhat.com> PR c/80097 * c-typeck.c (build_binary_op): Add EXCESS_PRECISION_EXPR only around optional COMPOUND_EXPR with ubsan instrumentation. * gcc.dg/ubsan/pr80097.c: New test. Added: branches/gcc-6-branch/gcc/testsuite/gcc.dg/ubsan/pr80097.c Modified: branches/gcc-6-branch/gcc/c/ChangeLog branches/gcc-6-branch/gcc/c/c-typeck.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Author: jakub Date: Tue May 30 08:16:31 2017 New Revision: 248661 URL: https://gcc.gnu.org/viewcvs?rev=248661&root=gcc&view=rev Log: Backported from mainline 2017-03-21 Jakub Jelinek <jakub@redhat.com> PR c/80097 * c-typeck.c (build_binary_op): Add EXCESS_PRECISION_EXPR only around optional COMPOUND_EXPR with ubsan instrumentation. * gcc.dg/ubsan/pr80097.c: New test. Added: branches/gcc-5-branch/gcc/testsuite/gcc.dg/ubsan/pr80097.c Modified: branches/gcc-5-branch/gcc/c/ChangeLog branches/gcc-5-branch/gcc/c/c-typeck.c branches/gcc-5-branch/gcc/testsuite/ChangeLog
Fixed.