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

            Bug ID: 110689
           Summary: problem of initializer list
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: irip at qq dot com
  Target Milestone: ---

In the code, declare a struct/class and define multiple types of list
initializers, then use list initializers, such as:

struct M {
    operator char() { return 'a'; }
} m;
struct S {
    S(std::initializer_list<int>) { flag = 1; }
    S(std::initializer_list<float>) { flag = 2; }
};
……
S s = { m };



Compiler error:
conversion from '<brace-enclosed initializer list>' to 'S' is ambiguous

This is allowed in the C++ standard and requires overloaded parsing when the
list is initialized.

Reply via email to