Given this code,

#include <initializer_list>

typedef std::initializer_list<int> init_list;

struct A {
  A (init_list list) { }
};

struct B {
  B (std::initializer_list<int> list) { }
};

int main (void) {
  A a { 0, 1, 1, 2}; // compiler error 
  B b { 0, 1, 1, 2};
}

I get a compiler error when trying to brace initialize an instance of struct A.
The specific error:

initializer_bug.cpp: In function ‘int main()’:
initializer_bug.cpp:14:19: error: no matching function for call to
‘A::A(<brace-enclosed initializer list>)’
initializer_bug.cpp:6:3: note: candidates are: A::A(init_list)
initializer_bug.cpp:5:10: note:                 A::A(const A&)

Compiled example code with g++ --std=c++0x initializer_bug.cpp -o
initializer_bug.

Using gcc version 4.5.1 20100617 (prerelease) (Debian 4.5.0-6)


-- 
           Summary: bug w/ typedefs and std::initializer_list<T>
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: admin at thefireflyproject dot us
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


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

Reply via email to