https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102535
Bug ID: 102535 Summary: __is_trivially_constructible rejects some trivial cases in aggregate initializations Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: de34 at live dot cn Target Milestone: --- It seems that gcc's __is_trivially_constructible (the underlying mechanism of std::is_trivially_constructible in libstdc++) gives inconsistent answers to whether aggregate initializations performed by direct-non-list-initializations (available since C++20) affect triviality of operations. #include <type_traits> #include <iostream> struct A { int x; }; struct B { float y; }; struct C { A a; B b; }; int main() { #if __cpp_aggregate_paren_init >= 201902L std::cout << std::is_constructible_v<C, A> << '\n' // 1 << std::is_constructible_v<C, A, B> << '\n' // 1 << !std::is_constructible_v<C, B> << '\n' // 1 << std::is_trivially_constructible_v<C, A> << '\n' // 1 << std::is_trivially_constructible_v<C, A, B> << '\n'; // 0, seems buggy #endif } According to the definitions, initialization of a C variable from A or A and B (both treated as xvalues according to [meta.unary.prop]/8) only calls trivial move constructors. It seems unreasonable that std::is_trivially_constructible_v<C, A> is true but std::is_trivially_constructible_v<C, A, B> is false, they should be both true in C++20. This bug has been existing since gcc 10.1.0, and is not fixed in 12.0.0 20210721: https://wandbox.org/permlink/L0ZLipQZLsCOqYcT https://wandbox.org/permlink/lBwowJpeFshRC03z