diff options
author | Nathaniel Shead <nathanieloshead@gmail.com> | 2023-10-28 16:04:52 +1100 |
---|---|---|
committer | Nathaniel Shead <nathanieloshead@gmail.com> | 2023-12-11 13:33:52 +1100 |
commit | 4719b6f5ae4d758f193a17bbd5fb6cbacd702a23 (patch) | |
tree | 8a49b8ba5c0727564bcb0743b825ce1c91cb10ba /ltsugar.m4 | |
parent | ab3daffcbf35566d468c3028e48068a481048baf (diff) | |
download | gcc-4719b6f5ae4d758f193a17bbd5fb6cbacd702a23.zip gcc-4719b6f5ae4d758f193a17bbd5fb6cbacd702a23.tar.gz gcc-4719b6f5ae4d758f193a17bbd5fb6cbacd702a23.tar.bz2 |
c++: Fix noexcept checking for trivial operations [PR96090]
This patch stops eager folding of trivial operations (construction and
assignment) from occurring when checking for noexceptness. This was
previously done in PR c++/53025, but only for copy/move construction,
and the __is_nothrow_xible builtins did not receive the same treatment
when they were added.
To handle `is_nothrow_default_constructible`, the patch also ensures
that when no parameters are passed we do value initialisation instead of
just building the constructor call: in particular, value-initialisation
doesn't necessarily actually invoke the constructor for trivial default
constructors, and so we need to handle this case as well.
This is contrary to the proposed resolution of CWG2820; for now we just
ensure it matches the behaviour of the `noexcept` operator and create
testcases formalising this, and if that issue gets accepted we can
revisit.
PR c++/96090
PR c++/100470
gcc/cp/ChangeLog:
* call.cc (build_over_call): Prevent folding of trivial special
members when checking for noexcept.
* method.cc (constructible_expr): Perform value-initialisation
for empty parameter lists.
(is_nothrow_xible): Treat as noexcept operator.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/noexcept81.C: New test.
* g++.dg/ext/is_nothrow_constructible7.C: New test.
* g++.dg/ext/is_nothrow_constructible8.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Diffstat (limited to 'ltsugar.m4')
0 files changed, 0 insertions, 0 deletions