public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113008] New: Trivially default constructible requires default member initializer before the end of its enclosing class
@ 2023-12-13 21:17 barry.revzin at gmail dot com
0 siblings, 0 replies; only message in thread
From: barry.revzin at gmail dot com @ 2023-12-13 21:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113008
Bug ID: 113008
Summary: Trivially default constructible requires default
member initializer before the end of its enclosing
class
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
This is related to bugs PR96645 and PR88165.
Consider this:
#include <type_traits>
template <typename T, int N>
struct Array {
T elems[N];
};
struct A {
struct B {
int i = 0;
};
static constexpr bool v1 = std::is_trivially_default_constructible_v<B>;
static constexpr bool v2 =
std::is_trivially_default_constructible_v<Array<B, 10>>;
};
Declaring v1 works (and it correctly evaluates to false).
Declaring v2 fails to compile entirely:
opt/compiler-explorer/gcc-trunk-20231213/include/c++/14.0.0/type_traits:3284:7:
required from 'constexpr const bool
std::is_trivially_default_constructible_v<Array<A::B, 10> >'
3284 | = __is_trivially_constructible(_Tp);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:14:37: required from here
14 | static constexpr bool v2 =
std::is_trivially_default_constructible_v<Array<B, 10>>;
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-trunk-20231213/include/c++/14.0.0/type_traits:3284:7:
error: default member initializer for 'A::B::i' required before the end of its
enclosing class
3284 | = __is_trivially_constructible(_Tp);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:10:15: note: defined here
10 | int i = 0;
| ^~~~
If we know that B isn't trivially default constructible (A::v1 is initialized
to false), then can't we likewise also know that Array<B, 10> isn't trivially
default constructible?
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-12-13 21:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13 21:17 [Bug c++/113008] New: Trivially default constructible requires default member initializer before the end of its enclosing class barry.revzin at gmail dot com
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).