Created attachment 40984 [details] Reproducer. GCC crashes with with -fsanitize=undefined option. Reproducer: extern signed char a; void foo () { 0 << ((647 > a) - 1); } Error: >$ g++ -fsanitize=undefined -c repr.cpp repr.cpp: In function ‘void foo()’: repr.cpp:3:24: internal compiler error: tree check: expected class ‘expression’, have ‘constant’ (integer_cst) in fold_comparison, at fold-const.c:8707 0 << ((647 > a) - 1); ^ 0x10100b7 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) /home/vsevolod/workspace/gcc-dev/trunk/gcc/tree.c:9867 0xa94317 expr_check(tree_node*, char const*, int, char const*) /home/vsevolod/workspace/gcc-dev/trunk/gcc/tree.h:3233 0xa94317 fold_comparison (...) GCC version: Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/home/vsevolod/workspace/gcc-dev/bin-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /home/vsevolod/workspace/gcc-dev/trunk/configure --prefix=/home/vsevolod/workspace/gcc-dev/bin-trunk Thread model: posix gcc version 7.0.1 20170315 (experimental) (GCC)
Mine.
Started with r230365 - Merge C++ delayed folding branch.
Author: mpolacek Date: Tue Mar 28 08:13:04 2017 New Revision: 246521 URL: https://gcc.gnu.org/viewcvs?rev=246521&root=gcc&view=rev Log: PR sanitizer/80067 * fold-const.c (fold_comparison): Use protected_set_expr_location instead of SET_EXPR_LOCATION. * c-c++-common/ubsan/shift-10.c: New test. Added: trunk/gcc/testsuite/c-c++-common/ubsan/shift-10.c Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog
Author: mpolacek Date: Tue Mar 28 08:16:27 2017 New Revision: 246522 URL: https://gcc.gnu.org/viewcvs?rev=246522&root=gcc&view=rev Log: PR sanitizer/80067 * fold-const.c (fold_comparison): Use protected_set_expr_location instead of SET_EXPR_LOCATION. * c-c++-common/ubsan/shift-10.c: New test. Added: branches/gcc-6-branch/gcc/testsuite/c-c++-common/ubsan/shift-10.c Modified: branches/gcc-6-branch/gcc/ChangeLog branches/gcc-6-branch/gcc/fold-const.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Fixed.