[llvm-bugs] [Bug 36077] New: Single-(non-list) element braced initializer argument rejects user defined conversion

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 24 08:41:57 PST 2018


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

            Bug ID: 36077
           Summary: Single-(non-list) element braced initializer argument
                    rejects user defined conversion
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

In the following, the copy list-initialization of the parameter of foo, which
is of non-aggregate class type, from the single-(non-list) element
braced-init-list should succeed through selection of A's copy constructor in
the second phase of [over.match.list]. GCC compiles this code, as does MSVC and
ICC.

This appears to be related to CWG 2076, the resolution of which is included in
C++17.

### SOURCE (<stdin>):
struct A { A(const A &); };
struct B { operator A() const; };

void foo(A);
void bar(const B &b) { foo({b}); }


### COMPILER INVOCATION COMMAND:
clang -cc1 -x c++ -std=c++17 -


### ACTUAL OUTPUT:
<stdin>:5:24: error: no matching function for call to 'foo'
void bar(const B &b) { foo({b}); }
                       ^~~
<stdin>:4:6: note: candidate function not viable: cannot convert initializer
list argument to 'A'
void foo(A);
     ^
1 error generated.


### EXPECTED OUTPUT:
(Clean compile).


### COMPILER VERSION INFO (clang -v):
clang version 7.0.0 (https://github.com/llvm-mirror/clang.git
39491d7b6098f96eb1f88d68068eb654c1e2bd81)
(https://github.com/llvm-mirror/llvm.git
c127e0c9742f746fe7198222bf6442b81787292e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

-- 
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/20180124/81f8896d/attachment-0001.html>


More information about the llvm-bugs mailing list