]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: ICE when shortening right shift [PR94955]
authorMarek Polacek <polacek@redhat.com>
Thu, 11 Jun 2020 20:26:41 +0000 (16:26 -0400)
committerMarek Polacek <polacek@redhat.com>
Thu, 11 Jun 2020 20:26:41 +0000 (16:26 -0400)
commit18436d87ff85282b200579cb8da496659632ad6b
tree505a5dfbf44ced41cb8fc918054505f041aaa8e5
parent53e91f867bd1c3773d37b2efb8875b8b1416a9d2
c++: ICE when shortening right shift [PR94955]

Since r10-6527 fold_for_warn calls maybe_constant_value, which means it
can fold more than it previously could.  In this testcase it means that
cp_build_binary_op/RSHIFT_EXPR set short_shift because now we were able
to fold op1 to an INTEGER_CST.  But then when actually performing the
shortening we crashed because cp_fold_rvalue wasn't able to fold as much
as f_f_w and so tree_int_cst_sgn crashed on a NOP_EXPR.  Therefore the
calls should probably match.

PR c++/94955
* typeck.c (cp_build_binary_op): Use fold_for_warn instead of
cp_fold_rvalue.

* g++.dg/cpp0x/constexpr-shift2.C: New test.
gcc/cp/typeck.c
gcc/testsuite/g++.dg/cpp0x/constexpr-shift2.C [new file with mode: 0644]