]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: value-dep but not type-dep decltype expr [PR105756]
authorPatrick Palka <ppalka@redhat.com>
Fri, 3 Jun 2022 18:58:22 +0000 (14:58 -0400)
committerPatrick Palka <ppalka@redhat.com>
Sat, 11 Jun 2022 11:45:13 +0000 (07:45 -0400)
commit47ea22015c90df31eae763c6c9e3e4b1fb801c3a
tree22038745c508f5187395c2d9ef341cd5fe451d79
parent8ca04b41bb1a7d0850e562d37206dfadbc1d64c6
c++: value-dep but not type-dep decltype expr [PR105756]

Here during ahead of time instantiation of the value-dependent but not
type-dependent decltype expression (5 % N) == 0, cp_build_binary_op folds
the operands of the == via cp_fully_fold, which performs speculative
constexpr evaluation, and from which we crash for (5 % N) due to the
value-dependence.

Since the operand folding performed by cp_build_binary_op appears to
be solely for sake of diagnosing overflow, and since these diagnostics
are suppressed when in an unevaluated context, this patch avoids this
crash by suppressing cp_build_binary_op's operand folding accordingly.

PR c++/105756

gcc/cp/ChangeLog:

* typeck.cc (cp_build_binary_op): Don't fold operands
when c_inhibit_evaluation_warnings.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/decltype82.C: New test.

(cherry picked from commit 0ecb6b906f215ec56df1a555139abe9ad95414fb)
gcc/cp/typeck.cc
gcc/testsuite/g++.dg/cpp0x/decltype82.C [new file with mode: 0644]