https://llvm.org/bugs/show_bug.cgi?id=27642

            Bug ID: 27642
           Summary: Clang ignores 'explicit' constructors in
                    copy-list-initialization of function argument
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangb...@nondot.org
          Reporter: e...@catmur.co.uk
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
    Classification: Unclassified

Per N2532=08-0042 (http://www.stroustrup.com/list-issues-2.pdf) chapter 4 the
following program should be rejected as ambiguous:

struct String1 { explicit String1(const char*); };
struct String2 { String2(const char*); }; 

void f(String1);
void f(String2);

int main() {
 f( {"asdf"} );  // error, ambiguous
} 

This was confirmed by CWG 1228 (http://wg21.cmeerw.net/cwg/issue1228):

    struct MyStore {
      explicit MyStore(int initialCapacity);
    };

    struct MyInt {
      MyInt(int i);
    };

    struct Printer {
      void operator()(MyStore const& s);
      void operator()(MyInt const& i);
    };

    void f() {
      Printer p;
      p({23});  // error, ambiguous
    }

gcc (6.1 and preceding versions) correctly rejects both these programs.

I don't like this behavior, but it is what over.match.list prescribes.

Possible follow up to bug 12120.

Discussion:
http://stackoverflow.com/questions/34622076/calling-an-explicit-constructor-with-a-braced-init-list-ambiguous-or-not?rq=1

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to