Here is a brief example that reproduces this βno viable conversionβ with lemon for clang, but valid for g ++ differences in compiler behavior.
live on godbolt
g ++ (4.9, 5.2) compiles this silently; whereas clang ++ (3.5, 3.7) compiles it
if a
using cast_type = A;
or
using cast_type = const A;
, but not with default
using cast_type = const A;
In this case, clang ++ (3.5) blames a = b :
testling.c++:25:9: error: no viable conversion from 'B' to 'A' a = b; ^ testling.c++:3:8: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'B' to 'const A &' for 1st argument struct A { ^ testling.c++:3:8: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'B' to 'A &&' for 1st argument struct A { ^ testling.c++:14:5: note: candidate function operator cast_type () const { ^ testling.c++:3:8: note: passing argument to parameter here struct A {
Regarding the 2011ΒΉ standard: Does clang ++ correctly say that it refuses to use default code, or does it agree with g ++ correctly?
Nota bene . This is not a question of whether const classifier on cast_type makes sense. It is about which compiler works standardly and only about that .
No. 2014 should not be of any significance here.
EDIT:
Please refrain from re-tagging this with a generic C ++ tag. First, I would like to know what behavior complies with the 2011 standard, and to maintain the commitment of the not to break existing (< 2011) code committees from the ansatz for now.
language-lawyer c ++ 11 g ++ clang ++ conversion-operator
decltype_auto
source share