GCC accepts the code below. Clang rejects it. 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 {
^