public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96090] New: Inconsistent querying of differring exception specifications of explicitly defaulted functions
@ 2020-07-07 0:22 johelegp at gmail dot com
2020-07-07 7:25 ` [Bug c++/96090] " redi at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: johelegp at gmail dot com @ 2020-07-07 0:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96090
Bug ID: 96090
Summary: Inconsistent querying of differring exception
specifications of explicitly defaulted functions
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: johelegp at gmail dot com
Target Milestone: ---
See https://godbolt.org/z/SiGMyX.
```C++
#include <type_traits>
using namespace std;
struct yesthrow_t
{
yesthrow_t() noexcept(false) = default;
yesthrow_t(const yesthrow_t&) noexcept(false) = default;
yesthrow_t( yesthrow_t&&) noexcept(false) = default;
yesthrow_t& operator=(const yesthrow_t&) noexcept(false) = default;
yesthrow_t& operator=( yesthrow_t&&) noexcept(false) = default;
};
static_assert(!is_nothrow_default_constructible_v<yesthrow_t>);
static_assert(!is_nothrow_copy_constructible_v< yesthrow_t>);
static_assert(!is_nothrow_copy_assignable_v< yesthrow_t>);
static_assert(!is_nothrow_move_constructible_v< yesthrow_t>);
static_assert(!is_nothrow_move_assignable_v< yesthrow_t>);
```
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00311.html calls out a single
case, but not this inconsistency.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96090] Inconsistent querying of differring exception specifications of explicitly defaulted functions
2020-07-07 0:22 [Bug c++/96090] New: Inconsistent querying of differring exception specifications of explicitly defaulted functions johelegp at gmail dot com
@ 2020-07-07 7:25 ` redi at gcc dot gnu.org
2021-08-29 0:17 ` [Bug c++/96090] noexcept operator of potentially-throwing defaulted function gives the wrong result johelegp at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-07 7:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96090
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
CC| |mpolacek at gcc dot gnu.org
Ever confirmed|0 |1
Last reconfirmed| |2020-07-07
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96090] noexcept operator of potentially-throwing defaulted function gives the wrong result
2020-07-07 0:22 [Bug c++/96090] New: Inconsistent querying of differring exception specifications of explicitly defaulted functions johelegp at gmail dot com
2020-07-07 7:25 ` [Bug c++/96090] " redi at gcc dot gnu.org
@ 2021-08-29 0:17 ` johelegp at gmail dot com
2023-10-28 8:23 ` nathanieloshead at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: johelegp at gmail dot com @ 2021-08-29 0:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96090
Johel Ernesto Guerrero Peña <johelegp at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |10.3.0, 11.2.0, 12.0
Keywords| |rejects-valid
Summary|Inconsistent querying of |noexcept operator of
|differring exception |potentially-throwing
|specifications of |defaulted function gives
|explicitly defaulted |the wrong result
|functions |
--- Comment #1 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Now they all give the wrong answer: https://godbolt.org/z/hroWqTExz.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96090] noexcept operator of potentially-throwing defaulted function gives the wrong result
2020-07-07 0:22 [Bug c++/96090] New: Inconsistent querying of differring exception specifications of explicitly defaulted functions johelegp at gmail dot com
2020-07-07 7:25 ` [Bug c++/96090] " redi at gcc dot gnu.org
2021-08-29 0:17 ` [Bug c++/96090] noexcept operator of potentially-throwing defaulted function gives the wrong result johelegp at gmail dot com
@ 2023-10-28 8:23 ` nathanieloshead at gmail dot com
2023-12-11 2:34 ` cvs-commit at gcc dot gnu.org
2024-02-06 14:42 ` mpolacek at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: nathanieloshead at gmail dot com @ 2023-10-28 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96090
Nathaniel Shead <nathanieloshead at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nathanieloshead at gmail dot com
--- Comment #2 from Nathaniel Shead <nathanieloshead at gmail dot com> ---
I'm working on a patch for this. But worth noting...
> static_assert(!is_nothrow_default_constructible_v<yesthrow_t>);
I'm not sure this is correct. By https://eel.is/c++draft/meta.unary.prop#9 this
is testing noexceptness of value-initialisation. And
https://eel.is/c++draft/dcl.init.general#9.1 says
> if T has either no default constructor ([class.default.ctor]) or
> a default constructor that is user-provided or deleted, then
> the object is default-initialized;
> otherwise, the object is zero-initialized and the semantic constraints
> for default-initialization are checked, and if T has a non-trivial
> default constructor, the object is default-initialized;
Since the default constructor here is not user-provided, and also trivial, the
object should not be default-initialized and thus the default constructor is
not called, and thus this is not potentially-throwing.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96090] noexcept operator of potentially-throwing defaulted function gives the wrong result
2020-07-07 0:22 [Bug c++/96090] New: Inconsistent querying of differring exception specifications of explicitly defaulted functions johelegp at gmail dot com
` (2 preceding siblings ...)
2023-10-28 8:23 ` nathanieloshead at gmail dot com
@ 2023-12-11 2:34 ` cvs-commit at gcc dot gnu.org
2024-02-06 14:42 ` mpolacek at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-11 2:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96090
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:
https://gcc.gnu.org/g:4719b6f5ae4d758f193a17bbd5fb6cbacd702a23
commit r14-6395-g4719b6f5ae4d758f193a17bbd5fb6cbacd702a23
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date: Sat Oct 28 16:04:52 2023 +1100
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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96090] noexcept operator of potentially-throwing defaulted function gives the wrong result
2020-07-07 0:22 [Bug c++/96090] New: Inconsistent querying of differring exception specifications of explicitly defaulted functions johelegp at gmail dot com
` (3 preceding siblings ...)
2023-12-11 2:34 ` cvs-commit at gcc dot gnu.org
@ 2024-02-06 14:42 ` mpolacek at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-06 14:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96090
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed, I guess.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-06 14:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 0:22 [Bug c++/96090] New: Inconsistent querying of differring exception specifications of explicitly defaulted functions johelegp at gmail dot com
2020-07-07 7:25 ` [Bug c++/96090] " redi at gcc dot gnu.org
2021-08-29 0:17 ` [Bug c++/96090] noexcept operator of potentially-throwing defaulted function gives the wrong result johelegp at gmail dot com
2023-10-28 8:23 ` nathanieloshead at gmail dot com
2023-12-11 2:34 ` cvs-commit at gcc dot gnu.org
2024-02-06 14:42 ` mpolacek at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).