Open hubert-reinterpretcast opened 5 years ago
I think the reason is that the following has not considered condition fully. It needs return ImplicitConversionSequence::Worse
so that the caller outside would not go to path to choose non-template candidate as first.
// In Microsoft mode, prefer an integral conversion to a
// floating-to-integral conversion if the integral conversion
// is between types of the same size.
// For example:
// void f(float);
// void f(int);
// int main {
// long a;
// f(a);
// }
// Here, MSVC will call f(int) instead of generating a compile error
// as clang will do in standard mode.
if (S.getLangOpts().MSVCCompat && SCS1.Second == ICK_Integral_Conversion &&
SCS2.Second == ICK_Floating_Integral &&
S.Context.getTypeSize(SCS1.getFromType()) ==
S.Context.getTypeSize(SCS1.getToType(2)))
return ImplicitConversionSequence::Better;
Extended Description
Overload resolution with
-fms-compatibility
seems to be dependent on the order of declarations. The overload sets f and g are parallels of each other, but parallel calls do not resolve the same.SOURCE ():
COMPILER INVOCATION COMMAND:
ACTUAL COMPILER OUTPUT:
EXPECTED COMPILER OUTPUT:
(Clean compile).
COMPILER VERSION INFO (
clang++ -v
):