public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101194] New: 7.2 Regression
@ 2021-06-24 13:43 yannick.lepennec+gcc at live dot fr
  2021-06-25  6:14 ` [Bug libstdc++/101194] [9/10/11/12 Regression] rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: yannick.lepennec+gcc at live dot fr @ 2021-06-24 13:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101194
           Summary: 7.2 Regression
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yannick.lepennec+gcc at live dot fr
  Target Milestone: ---

Dear Maintainers,

Obligatory godbolt: https://godbolt.org/z/KnMnc7P57
Since GCC 7.2:

$ g++ -std=c++17 -Wall -Wextra -pedantic-errors

#include <array>

struct nodefault {
    nodefault(int) {}
};

int main() {
    std::array<nodefault, 1> arr1{ nodefault{1} }; // OK
    std::array<nodefault, 1> arr2{ arr1[0] }; // Error???
}

Gives:

main.cpp: In function 'int main()':
main.cpp:9:44: error: no matching function for call to 'nodefault::nodefault()'
     std::array<nodefault, 1> arr2{ arr1[0] }; // Error???
                                            ^
main.cpp:4:5: note: candidate: nodefault::nodefault(int)
     nodefault(int) {}
     ^~~~~~~~~
main.cpp:4:5: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(const nodefault&)
 struct nodefault {
        ^~~~~~~~~
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(nodefault&&)
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:9:44: error: no matching function for call to 'nodefault::nodefault()'
     std::array<nodefault, 1> arr2{ arr1[0] }; // Error???
                                            ^
main.cpp:4:5: note: candidate: nodefault::nodefault(int)
     nodefault(int) {}
     ^~~~~~~~~
main.cpp:4:5: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(const nodefault&)
 struct nodefault {
        ^~~~~~~~~
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(nodefault&&)
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:9:44: error: no matching function for call to 'nodefault::nodefault()'
     std::array<nodefault, 1> arr2{ arr1[0] }; // Error???
                                            ^
main.cpp:4:5: note: candidate: nodefault::nodefault(int)
     nodefault(int) {}
     ^~~~~~~~~
main.cpp:4:5: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(const nodefault&)
 struct nodefault {
        ^~~~~~~~~
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(nodefault&&)
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:9:44: error: no matching function for call to 'nodefault::nodefault()'
     std::array<nodefault, 1> arr2{ arr1[0] }; // Error???
                                            ^
main.cpp:4:5: note: candidate: nodefault::nodefault(int)
     nodefault(int) {}
     ^~~~~~~~~
main.cpp:4:5: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(const nodefault&)
 struct nodefault {
        ^~~~~~~~~
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(nodefault&&)
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:9:44: error: no matching function for call to 'nodefault::nodefault()'
     std::array<nodefault, 1> arr2{ arr1[0] }; // Error???
                                            ^
main.cpp:4:5: note: candidate: nodefault::nodefault(int)
     nodefault(int) {}
     ^~~~~~~~~
main.cpp:4:5: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(const nodefault&)
 struct nodefault {
        ^~~~~~~~~
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(nodefault&&)
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:9:44: error: no matching function for call to 'nodefault::nodefault()'
     std::array<nodefault, 1> arr2{ arr1[0] }; // Error???
                                            ^
main.cpp:4:5: note: candidate: nodefault::nodefault(int)
     nodefault(int) {}
     ^~~~~~~~~
main.cpp:4:5: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(const nodefault&)
 struct nodefault {
        ^~~~~~~~~
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided
main.cpp:3:8: note: candidate: constexpr nodefault::nodefault(nodefault&&)
main.cpp:3:8: note:   candidate expects 1 argument, 0 provided

---

GCC 7.2 and above accept the same code with -std=c++14. GCC 7.1 accepts it with
either. The error message seems to have gotten shorter in more recent GCC, but
is still present. I have bisected this to
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=0634d9fe36e8ced1c6046759f9ce1d2655c8d731

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

* [Bug libstdc++/101194] [9/10/11/12 Regression]
  2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
@ 2021-06-25  6:14 ` rguenth at gcc dot gnu.org
  2021-06-25  6:50 ` [Bug c++/101194] [9/10/11/12 Regression] aggregate init requires default constructor marxin at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-25  6:14 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |libstdc++
   Target Milestone|---                         |9.5
           Keywords|                            |rejects-valid
            Summary|7.2 Regression              |[9/10/11/12 Regression]

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

* [Bug c++/101194] [9/10/11/12 Regression] aggregate init requires default constructor
  2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
  2021-06-25  6:14 ` [Bug libstdc++/101194] [9/10/11/12 Regression] rguenth at gcc dot gnu.org
@ 2021-06-25  6:50 ` marxin at gcc dot gnu.org
  2021-06-25  6:50 ` marxin at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-06-25  6:50 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r8-525-g54069e595976eb55.

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

* [Bug c++/101194] [9/10/11/12 Regression] aggregate init requires default constructor
  2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
  2021-06-25  6:14 ` [Bug libstdc++/101194] [9/10/11/12 Regression] rguenth at gcc dot gnu.org
  2021-06-25  6:50 ` [Bug c++/101194] [9/10/11/12 Regression] aggregate init requires default constructor marxin at gcc dot gnu.org
@ 2021-06-25  6:50 ` marxin at gcc dot gnu.org
  2021-06-25 20:17 ` ppalka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-06-25  6:50 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-06-25
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

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

* [Bug c++/101194] [9/10/11/12 Regression] aggregate init requires default constructor
  2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
                   ` (2 preceding siblings ...)
  2021-06-25  6:50 ` marxin at gcc dot gnu.org
@ 2021-06-25 20:17 ` ppalka at gcc dot gnu.org
  2021-06-28 20:21 ` ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-25 20:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
                 CC|                            |ppalka at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/101194] [9/10/11/12 Regression] aggregate init requires default constructor
  2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
                   ` (3 preceding siblings ...)
  2021-06-25 20:17 ` ppalka at gcc dot gnu.org
@ 2021-06-28 20:21 ` ppalka at gcc dot gnu.org
  2021-07-01  0:45 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-28 20:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Reduced rejects-valid testcase:

struct nodefault {
  constexpr nodefault(int) { }
};
constexpr nodefault x[1] = { nodefault{0} };
constexpr nodefault y = x[0];


We started rejecting this testcase even earlier, after r7-2520.

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

* [Bug c++/101194] [9/10/11/12 Regression] aggregate init requires default constructor
  2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
                   ` (4 preceding siblings ...)
  2021-06-28 20:21 ` ppalka at gcc dot gnu.org
@ 2021-07-01  0:45 ` cvs-commit at gcc dot gnu.org
  2021-07-13 14:03 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-01  0:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:a688c284dd3848b6c4ea553035f0f9769fb4fbc9

commit r12-1946-ga688c284dd3848b6c4ea553035f0f9769fb4fbc9
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Jun 30 20:44:52 2021 -0400

    c++: cxx_eval_array_reference and empty elem type [PR101194]

    Here the initializer for x is represented as an empty CONSTRUCTOR due to
    its empty element type.  So during constexpr evaluation of the ARRAY_REF
    x[0], we end up trying to value initialize the omitted element at index 0,
    which fails because the element type is not default constructible.

    This patch makes cxx_eval_array_reference specifically handle the case
    where the element type is an empty type.

            PR c++/101194

    gcc/cp/ChangeLog:

            * constexpr.c (cxx_eval_array_reference): When the element type
            is an empty type and the corresponding element is omitted, just
            return an empty CONSTRUCTOR instead of attempting value
            initialization.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/constexpr-empty16.C: New test.

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

* [Bug c++/101194] [9/10/11/12 Regression] aggregate init requires default constructor
  2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
                   ` (5 preceding siblings ...)
  2021-07-01  0:45 ` cvs-commit at gcc dot gnu.org
@ 2021-07-13 14:03 ` cvs-commit at gcc dot gnu.org
  2021-07-13 14:07 ` [Bug c++/101194] [9/10 " ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-13 14:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:1b57a9fb90552e52f2a121e2ae12534484b39859

commit r11-8731-g1b57a9fb90552e52f2a121e2ae12534484b39859
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Jun 30 20:44:52 2021 -0400

    c++: cxx_eval_array_reference and empty elem type [PR101194]

    Here the initializer for x is represented as an empty CONSTRUCTOR due to
    its empty element type.  So during constexpr evaluation of the ARRAY_REF
    x[0], we end up trying to value initialize the omitted element at index 0,
    which fails because the element type is not default constructible.

    This patch makes cxx_eval_array_reference specifically handle the case
    where the element type is an empty type.

            PR c++/101194

    gcc/cp/ChangeLog:

            * constexpr.c (cxx_eval_array_reference): When the element type
            is an empty type and the corresponding element is omitted, just
            return an empty CONSTRUCTOR instead of attempting value
            initialization.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/constexpr-empty16.C: New test.

    (cherry picked from commit a688c284dd3848b6c4ea553035f0f9769fb4fbc9)

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

* [Bug c++/101194] [9/10 Regression] aggregate init requires default constructor
  2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
                   ` (6 preceding siblings ...)
  2021-07-13 14:03 ` cvs-commit at gcc dot gnu.org
@ 2021-07-13 14:07 ` ppalka at gcc dot gnu.org
  2022-05-11 17:25 ` cvs-commit at gcc dot gnu.org
  2022-05-27  9:05 ` [Bug c++/101194] [9 " rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-07-13 14:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[9/10/11/12 Regression]     |[9/10 Regression] aggregate
                   |aggregate init requires     |init requires default
                   |default constructor         |constructor

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for 11.2/12 so far

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

* [Bug c++/101194] [9/10 Regression] aggregate init requires default constructor
  2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
                   ` (7 preceding siblings ...)
  2021-07-13 14:07 ` [Bug c++/101194] [9/10 " ppalka at gcc dot gnu.org
@ 2022-05-11 17:25 ` cvs-commit at gcc dot gnu.org
  2022-05-27  9:05 ` [Bug c++/101194] [9 " rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-11 17:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:5fcedef529c7564b6485ab2893c08865798a66ec

commit r10-10716-g5fcedef529c7564b6485ab2893c08865798a66ec
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Jun 30 20:44:52 2021 -0400

    c++: cxx_eval_array_reference and empty elem type [PR101194]

    Here the initializer for x is represented as an empty CONSTRUCTOR due to
    its empty element type.  So during constexpr evaluation of the ARRAY_REF
    x[0], we end up trying to value initialize the omitted element at index 0,
    which fails because the element type is not default constructible.

    This patch makes cxx_eval_array_reference specifically handle the case
    where the element type is an empty type.

            PR c++/101194

    gcc/cp/ChangeLog:

            * constexpr.c (cxx_eval_array_reference): When the element type
            is an empty type and the corresponding element is omitted, just
            return an empty CONSTRUCTOR instead of attempting value
            initialization.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/constexpr-empty16.C: New test.

    (cherry picked from commit a688c284dd3848b6c4ea553035f0f9769fb4fbc9)

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

* [Bug c++/101194] [9 Regression] aggregate init requires default constructor
  2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
                   ` (8 preceding siblings ...)
  2022-05-11 17:25 ` cvs-commit at gcc dot gnu.org
@ 2022-05-27  9:05 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:05 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
      Known to fail|                            |9.5.0
   Target Milestone|9.5                         |10.4

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for GCC 10.4.

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

end of thread, other threads:[~2022-05-27  9:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 13:43 [Bug c++/101194] New: 7.2 Regression yannick.lepennec+gcc at live dot fr
2021-06-25  6:14 ` [Bug libstdc++/101194] [9/10/11/12 Regression] rguenth at gcc dot gnu.org
2021-06-25  6:50 ` [Bug c++/101194] [9/10/11/12 Regression] aggregate init requires default constructor marxin at gcc dot gnu.org
2021-06-25  6:50 ` marxin at gcc dot gnu.org
2021-06-25 20:17 ` ppalka at gcc dot gnu.org
2021-06-28 20:21 ` ppalka at gcc dot gnu.org
2021-07-01  0:45 ` cvs-commit at gcc dot gnu.org
2021-07-13 14:03 ` cvs-commit at gcc dot gnu.org
2021-07-13 14:07 ` [Bug c++/101194] [9/10 " ppalka at gcc dot gnu.org
2022-05-11 17:25 ` cvs-commit at gcc dot gnu.org
2022-05-27  9:05 ` [Bug c++/101194] [9 " rguenth 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).