[llvm-bugs] [Bug 27642] New: Clang ignores 'explicit' constructors in copy-list-initialization of function argument

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 4 07:06:24 PDT 2016


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: unassignedclangbugs at nondot.org
          Reporter: ed at catmur.co.uk
                CC: dgregor at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160504/3d22d5d9/attachment.html>


More information about the llvm-bugs mailing list