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

            Bug ID: 27949
           Summary: implicit conversions and const rvalues
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangb...@nondot.org
          Reporter: enieb...@boost.org
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org
    Classification: Unclassified

GCC accepts the code below. Clang rejects it in C++11 mode and higher, but
accepts it in C++98 mode. Who is right?

struct ovrMatrix4f {
};

class Matrix4 {
public:
  operator const ovrMatrix4f () const {
    ovrMatrix4f result;
    return result;
  }
};

void ok() {
  Matrix4 from;
  ovrMatrix4f to = from; // that one is fine
}

void bad() {
  Matrix4 from;
  ovrMatrix4f to;
  to = from; // compilation fails here
}

Clang says:

test.cpp:20:8: error: no viable conversion from 'Matrix4' to 'ovrMatrix4f'
  to = from; // compilation fails here
       ^~~~
test.cpp:1:8: note: candidate constructor (the implicit copy constructor) not
viable: no known conversion from 'Matrix4' to
      'const ovrMatrix4f &' for 1st argument
struct ovrMatrix4f {
       ^
test.cpp:1:8: note: candidate constructor (the implicit move constructor) not
viable: no known conversion from 'Matrix4' to
      'ovrMatrix4f &&' for 1st argument
struct ovrMatrix4f {
       ^
test.cpp:6:3: note: candidate function
  operator const ovrMatrix4f () const {
  ^
test.cpp:1:8: note: passing argument to parameter here
struct ovrMatrix4f {
       ^

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to