[LLVMdev] initialization list with conversion operator dont work properly and report error

Mayur Pandey mayurthebond at gmail.com
Mon Sep 23 23:43:19 PDT 2013


for the following code:

struct X
{
  X();
};

struct Y
{
  operator X() const;
};

X a = { Y() };    // reports error: no matching constructor for
initialization of 'X'
X aa = Y();  // works fine


clang when compiled with std=c++11 gives compilation errors as:


testfile.C:11:3: error: no matching constructor for initialization of 'X'
X a = { Y() };    // reports error: no matching constructor for
initialization of 'X'
  ^   ~~~~~~~
testfile.C:1:8: note: candidate constructor (the implicit copy constructor)
not viable: no known conversion from 'Y' to 'const X &' for 1st
      argument
struct X
       ^
testfile.C:1:8: note: candidate constructor (the implicit move constructor)
not viable: no known conversion from 'Y' to 'X &&' for 1st
      argument
struct X
       ^
testfile.C:3:3: note: candidate constructor not viable: requires 0
arguments, but 1 was provided
  X();
  ^
1 error generated.






-- 
Thanx & Regards
*Mayur Pandey *
+91-9742959541
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130924/86017a0b/attachment.html>


More information about the llvm-dev mailing list