I guess it depends on your code base and whether you find more bugs from return values implicitly changed with the usual arithmetic conversions or from other aspects of C++.
I have not encountered that many issues with the usual arithmetic conversions on return types, at least not in a way that auto would prevent. Clearly your experience is different.
Perhaps we can both agree that it would be nice to force explicit numerical conversions?
You can _almost_ get this by wrapping the arithmetic types in a union with only one member, but that may incur a performance hit, which is often not a viable trade off.
> I'll take "unintelligible compile errors" any day over subtle runtime bugs.
As would the rest of us, but that’s not the choice that auto gives you. auto can cause subtle bugs with class types. It doesn’t necessarily protect you from integer narrowing, either, as you eventually have to give the compiler a concrete non-auto type.
I have not encountered that many issues with the usual arithmetic conversions on return types, at least not in a way that auto would prevent. Clearly your experience is different.
Perhaps we can both agree that it would be nice to force explicit numerical conversions?
You can _almost_ get this by wrapping the arithmetic types in a union with only one member, but that may incur a performance hit, which is often not a viable trade off.
> I'll take "unintelligible compile errors" any day over subtle runtime bugs.
As would the rest of us, but that’s not the choice that auto gives you. auto can cause subtle bugs with class types. It doesn’t necessarily protect you from integer narrowing, either, as you eventually have to give the compiler a concrete non-auto type.