[Bug c++/101194] New: 7.2 Regression

yannick.lepennec+gcc at live dot fr gcc-bugzilla@gcc.gnu.org
Thu Jun 24 13:43:20 GMT 2021


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


More information about the Gcc-bugs mailing list