[Bug c++/60437] New: [C++11] Bogus "error: no matching function for call to 'X::X(<brace-enclosed initializer list>)'"

daniel.kruegler at googlemail dot com gcc-bugzilla@gcc.gnu.org
Fri Mar 7 20:40:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60437

            Bug ID: 60437
           Summary: [C++11] Bogus "error: no matching function for call to
                    'X::X(<brace-enclosed initializer list>)'"
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppluzhnikov at google dot com
                CC: daniel.kruegler at googlemail dot com
                CC: daniel.kruegler at googlemail dot com

Using current trunk
g++ (GCC) 4.9.0 20140305 (experimental)


g++ -c t.cc -std=c++11
t.cc: In function 'void f()':
t.cc:10:8: error: no matching function for call to 'X::X(<brace-enclosed
initializer list>)'
   X x{1};
        ^
t.cc:10:8: note: candidates are:
t.cc:6:3: note: X::X(std::initializer_list<int>)
   X(std::initializer_list<int> init = std::initializer_list<int>()){}
   ^
t.cc:6:3: note:   no known conversion for argument 1 from 'int' to
'std::initializer_list<int>'
t.cc:3:7: note: constexpr X::X(const X&)
 class X {
       ^
t.cc:3:7: note:   no known conversion for argument 1 from 'int' to 'const X&'
t.cc:3:7: note: constexpr X::X(X&&)
t.cc:3:7: note:   no known conversion for argument 1 from 'int' to 'X&&'


Code accepted by clang, and is correct (AFAICT):

#include <initializer_list>

class X {
 public:
  // X(std::initializer_list<int> init);  // OK
  X(std::initializer_list<int> init = std::initializer_list<int>()){}
};

void f(){
  X x{1};
}



More information about the Gcc-bugs mailing list