Open llvmbot opened 8 years ago
This code is ill-formed in C++11 onwards, because you can't implicitly convert a string literal to a (non-const) char*
.
We fixed Clang 3.5 to properly implement this rule in overload resolution -- as an extension, we still allow the conversion of ""
to char*
, but it's considered worse than every other conversion, so we only do it when there is no other viable function.
As as consequence, we prefer to use D
's copy constructor over D
's char*
constructor. D
's copy construction works because we can't recursively use the copy constructor from within it, so we choose the char*
constructor in the recursive call as it is then the only viable function.
The diagnostic here is pretty bad, but the workaround is simple: make your code valid C++11 by taking the string literal as a const char*
.
Extended Description
The following code compiles successfully in Clang 3.4 and GCC 5.2. Clang 3.5 and higher issues an error in C++11 mode.