User defined conversion operations don't work as expected (operator T() is actually never called), only implicit conversions happen.
While this is okay when lets say assigning variables, its a nightmare when calling functions.
Also all this sits on DXC's rather flaky overload resolution.
Is your feature request related to a problem? Please describe.
This sort code compiles without any warning
https://godbolt.org/z/z4c74TEjW
https://godbolt.org/z/84KsEbPvT
Yes in and out aren't supposed to be references, however I'd appreciate not letting such hidden conversions happen in a language thats supposed to resemble C or C++ (with hopefully some strong typing) and implement on the Clang stack.
This is the sort of stuff that I'd have to care about to not get caught out in Python or JavaScript.
Describe the solution you'd like
-fno-implicit-argument-conversions which disables conversions happenning for in, out and inout function arguments.
It would still be useful to allow implicit copies for arguments not decorated with anything.
Also for that to kick in without breaking SFINAE/overload-resolution (so one can use to detect presence / pick the correct overload to call).
The very least I'd want is a warning whenever such a conversion happens behind my back.
Describe alternatives you've considered
Nothing really cuts it for this usecase.
Additional context
This has come up before when I was trying to write "method presence" detectors with SFINAE and due to there being no constexpr function reference type, the only way we could test for a method presence was with checking things like sizeof(declval<S>().someMethod(declval<Arg0>())).
However the problem was that due to implicit conversions for argument inputs, nearly anything matches float someMethod(in uint32_t)
User defined conversion operations don't work as expected (
operator T()is actually never called), only implicit conversions happen.While this is okay when lets say assigning variables, its a nightmare when calling functions.
Also all this sits on DXC's rather flaky overload resolution.
Is your feature request related to a problem? Please describe.
This sort code compiles without any warning
https://godbolt.org/z/z4c74TEjW
https://godbolt.org/z/84KsEbPvT
Yes
inandoutaren't supposed to be references, however I'd appreciate not letting such hidden conversions happen in a language thats supposed to resemble C or C++ (with hopefully some strong typing) and implement on the Clang stack.This is the sort of stuff that I'd have to care about to not get caught out in Python or JavaScript.
Describe the solution you'd like
-fno-implicit-argument-conversionswhich disables conversions happenning forin,outandinoutfunction arguments.It would still be useful to allow implicit copies for arguments not decorated with anything.
Also for that to kick in without breaking SFINAE/overload-resolution (so one can use to detect presence / pick the correct overload to call).
The very least I'd want is a warning whenever such a conversion happens behind my back.
Describe alternatives you've considered
Nothing really cuts it for this usecase.
Additional context
This has come up before when I was trying to write "method presence" detectors with SFINAE and due to there being no
constexprfunction reference type, the only way we could test for a method presence was with checking things likesizeof(declval<S>().someMethod(declval<Arg0>())).However the problem was that due to implicit conversions for argument inputs, nearly anything matches
float someMethod(in uint32_t)