diff options
author | Marek Polacek <polacek@redhat.com> | 2023-03-06 18:06:39 -0500 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2023-03-07 10:13:53 -0500 |
commit | e4692319fd5fc7d740436e8bb338f44cb8df6c58 (patch) | |
tree | 5b6a208abfe92c5d9bfa244c80c2e3dd830f5031 /gcc/cp/constexpr.cc | |
parent | e09bc034d1b4d692b409fa5af52ae34480a6f4dc (diff) | |
download | gcc-e4692319fd5fc7d740436e8bb338f44cb8df6c58.zip gcc-e4692319fd5fc7d740436e8bb338f44cb8df6c58.tar.gz gcc-e4692319fd5fc7d740436e8bb338f44cb8df6c58.tar.bz2 |
c++: noexcept and copy elision [PR109030]
When processing a noexcept, constructors aren't elided: build_over_call
has
/* It's unsafe to elide the constructor when handling
a noexcept-expression, it may evaluate to the wrong
value (c++/53025). */
&& (force_elide || cp_noexcept_operand == 0))
so the assert I added recently needs to be relaxed a little bit.
PR c++/109030
gcc/cp/ChangeLog:
* constexpr.cc (cxx_eval_call_expression): Relax assert.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/noexcept77.C: New test.
Diffstat (limited to 'gcc/cp/constexpr.cc')
-rw-r--r-- | gcc/cp/constexpr.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index 3079561..8683c00 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -2869,7 +2869,11 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, /* We used to shortcut trivial constructor/op= here, but nowadays we can only get a trivial function here with -fno-elide-constructors. */ - gcc_checking_assert (!trivial_fn_p (fun) || !flag_elide_constructors); + gcc_checking_assert (!trivial_fn_p (fun) + || !flag_elide_constructors + /* We don't elide constructors when processing + a noexcept-expression. */ + || cp_noexcept_operand); bool non_constant_args = false; new_call.bindings |