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

* [Bug c++/102535] __is_trivially_constructible rejects some trivial cases in aggregate initializations
  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 ` ppalka at gcc dot gnu.org
  2021-09-30 21:51 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-09-30 14:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102535

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-09-30
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
                 CC|                            |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/102535] __is_trivially_constructible rejects some trivial cases in aggregate initializations
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-30 21:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102535

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:9845c52db38f15740861435f38f7e5ad8a8de2ec

commit r12-3997-g9845c52db38f15740861435f38f7e5ad8a8de2ec
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Sep 30 17:34:23 2021 -0400

    c++: __is_trivially_xible and multi-arg aggr paren init [PR102535]

    is_xible_helper assumes only 0- and 1-argument ctors can be trivial, but
    C++20 aggregate paren init means multi-arg ctors can now be trivial too.
    This patch relaxes the relevant early exit check accordingly.

            PR c++/102535

    gcc/cp/ChangeLog:

            * method.c (is_xible_helper): Don't exit early for multi-arg
            ctors in C++20.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/is_trivially_constructible7.C: New test.

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

* [Bug c++/102535] __is_trivially_constructible rejects some trivial cases in aggregate initializations
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-05  8:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102535

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:7646847df71e57edca5ec5b8c3c3dc4550dcb49d

commit r12-4181-g7646847df71e57edca5ec5b8c3c3dc4550dcb49d
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Oct 5 09:32:11 2021 +0100

    libstdc++: Fix testcase for newly-implemented C++20 semantics [PR102535]

    libstdc++-v3/ChangeLog:

            PR c++/102535
            * testsuite/20_util/is_trivially_constructible/value.cc: Adjust
            expected value for C++20.

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

* [Bug c++/102535] __is_trivially_constructible rejects some trivial cases in aggregate initializations
  2021-09-30  2:45 [Bug c++/102535] New: __is_trivially_constructible rejects some trivial cases in aggregate initializations de34 at live dot cn
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-06 14:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102535

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:d80c0e4584acc204ca9a2f8880ad455fef48371f

commit r11-9085-gd80c0e4584acc204ca9a2f8880ad455fef48371f
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Sep 30 17:54:17 2021 -0400

    c++: __is_trivially_xible and multi-arg aggr paren init [PR102535]

    is_xible_helper assumes only 0- and 1-argument ctors can be trivial, but
    C++20 aggregate paren init means multi-arg ctors can now be trivial too.
    This patch relaxes the relevant early exit check accordingly.

            PR c++/102535

    gcc/cp/ChangeLog:

            * method.c (is_xible_helper): Don't exit early for multi-arg
            ctors in C++20.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/is_trivially_constructible7.C: New test.

    (cherry picked from commit 9845c52db38f15740861435f38f7e5ad8a8de2ec)

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

* [Bug c++/102535] __is_trivially_constructible rejects some trivial cases in aggregate initializations
  2021-09-30  2:45 [Bug c++/102535] New: __is_trivially_constructible rejects some trivial cases in aggregate initializations de34 at live dot cn
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-12 11:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102535

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:7b4e6d75b18dbb52bf507dbfd4c8e694e476d2af

commit r11-9120-g7b4e6d75b18dbb52bf507dbfd4c8e694e476d2af
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Oct 5 09:32:11 2021 +0100

    libstdc++: Fix testcase for newly-implemented C++20 semantics [PR102535]

    libstdc++-v3/ChangeLog:

            PR c++/102535
            * testsuite/20_util/is_trivially_constructible/value.cc: Adjust
            expected value for C++20.

    (cherry picked from commit 7646847df71e57edca5ec5b8c3c3dc4550dcb49d)

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

* [Bug c++/102535] __is_trivially_constructible rejects some trivial cases in aggregate initializations
  2021-09-30  2:45 [Bug c++/102535] New: __is_trivially_constructible rejects some trivial cases in aggregate initializations de34 at live dot cn
                   ` (4 preceding siblings ...)
  2021-10-12 11:00 ` cvs-commit at gcc dot gnu.org
@ 2021-10-12 13:33 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-12 13:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102535

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |11.3
             Status|ASSIGNED                    |RESOLVED

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 11.3/12

^ 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).