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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to