[LLVMbugs] [Bug 21991] New: Conversion operator not considered in braced init list

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 19 14:04:43 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=21991

            Bug ID: 21991
           Summary: Conversion operator not considered in braced init list
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tavianator at tavianator.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 13581
  --> http://llvm.org/bugs/attachment.cgi?id=13581&action=edit
Reproducer

The following simple program gives a compilation error with clang++, while g++
compiles it with no trouble:

$ cat braced-explicit.cpp
class Foo
{
public:
  Foo();
};

class Bar
{
public:
  operator Foo() const;
};

Foo a{Bar{}};
Foo b(Bar{});

$ g++ -std=c++11 -Wall -c braced-explicit.cpp
$ clang++ -std=c++11 -Wall -c braced-explicit.cpp -save-temps
braced-explicit.cpp:13:5: error: no matching constructor for initialization of
'Foo'
Foo a{Bar{}};
    ^~~~~~~~
braced-explicit.cpp:1:7: note: candidate constructor (the implicit copy
constructor) not viable: no known conversion from 'Bar' to 'const Foo &' for
1st argument
class Foo
      ^
braced-explicit.cpp:1:7: note: candidate constructor (the implicit move
constructor) not viable: no known conversion from 'Bar' to 'Foo &&' for 1st
argument
class Foo
      ^
braced-explicit.cpp:4:3: note: candidate constructor not viable: requires 0
arguments, but 1 was provided
  Foo();
  ^
1 error generated.

-- 
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/20141219/5776eb22/attachment.html>


More information about the llvm-bugs mailing list