public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102535] New: __is_trivially_constructible rejects some trivial cases in aggregate initializations
@ 2021-09-30  2:45 de34 at live dot cn
  2021-09-30 14:59 ` [Bug c++/102535] " ppalka at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: de34 at live dot cn @ 2021-09-30  2:45 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-12 13:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30  2:45 [Bug c++/102535] New: __is_trivially_constructible rejects some trivial cases in aggregate initializations de34 at live dot cn
2021-09-30 14:59 ` [Bug c++/102535] " ppalka at gcc dot gnu.org
2021-09-30 21:51 ` cvs-commit at gcc dot gnu.org
2021-10-05  8:36 ` cvs-commit at gcc dot gnu.org
2021-10-06 14:15 ` cvs-commit at gcc dot gnu.org
2021-10-12 11:00 ` cvs-commit at gcc dot gnu.org
2021-10-12 13:33 ` ppalka 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).