[llvm-bugs] [Bug 25619] New: no matching conversion for functional-style cast from 'void' to 'X'

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 23 20:00:10 PST 2015


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

            Bug ID: 25619
           Summary: no matching conversion for functional-style cast from
                    'void' to 'X'
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: matthew at dempsky.org
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

G++ produces a better diagnostic here.  In particular, I don't understand why
clang++ is talking about 'void'.

$ cat x.cc
struct X {
  explicit X(int, int, int);
};

void F() {
  X({1, 2, 3});
}

$ g++-4.8 -c x.cc -std=c++11
x.cc: In function ‘void F()’:
x.cc:6:14: error: converting to ‘X’ from initializer list would use explicit
constructor ‘X::X(int, int, int)’
   X({1, 2, 3});
              ^

$ clang++-3.5 -c x.cc -std=c++11
x.cc:6:3: error: no matching conversion for functional-style cast from 'void'
to 'X'
  X({1, 2, 3});
  ^~~~~~~~~~~
x.cc:1:8: note: candidate constructor (the implicit copy constructor) not
viable: cannot convert initializer list
      argument to 'const X'
struct X {
       ^
x.cc:1:8: note: candidate constructor (the implicit move constructor) not
viable: cannot convert initializer list
      argument to 'X'
struct X {
       ^
x.cc:2:12: note: candidate constructor not viable: requires 3 arguments, but 1
was provided
  explicit X(int, int, int);
           ^
1 error generated.

$ clang++-3.5 --version
Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on
LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix

-- 
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/20151124/5e9112e4/attachment.html>


More information about the llvm-bugs mailing list