<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Clang ignores 'explicit' constructors in copy-list-initialization of function argument"
   href="https://llvm.org/bugs/show_bug.cgi?id=27642">27642</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang ignores 'explicit' constructors in copy-list-initialization of function argument
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ed@catmur.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Per N2532=08-0042 (<a href="http://www.stroustrup.com/list-issues-2.pdf">http://www.stroustrup.com/list-issues-2.pdf</a>) 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 (<a href="http://wg21.cmeerw.net/cwg/issue1228">http://wg21.cmeerw.net/cwg/issue1228</a>):

    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 <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Clang ignores 'explicit' constructors in copy-list-initialization"
   href="show_bug.cgi?id=12120">bug 12120</a>.

Discussion:
<a href="http://stackoverflow.com/questions/34622076/calling-an-explicit-constructor-with-a-braced-init-list-ambiguous-or-not?rq=1">http://stackoverflow.com/questions/34622076/calling-an-explicit-constructor-with-a-braced-init-list-ambiguous-or-not?rq=1</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>