How to turn this warning off?
Sergei Organov
osv@javad.com
Thu May 31 14:22:00 GMT 2007
Tom St Denis <tstdenis@ellipticsemi.com> writes:
> Sergei Organov wrote:
>> Tom St Denis <tstdenis@ellipticsemi.com> writes:
>>
>>> Have you considered not passing a float? Or performing a cast?
>>>
>>
>> Yes I had. I do want implicit conversion in some of those cases.
>>
>> I'd be happy to add a cast, but there is no way in C/C++ to say: "cast it
>> to the actual type of the function argument".
>>
> Unless you're using third party code that continually changes (which
> would be bad anyways) you should be able to look at the prototype and
> work from that. It shouldn't be a mystery as to what a function
> requires.
Any alive code changes, being it first party, second party, or whatever.
Implicit conversion just fits better in some cases.
>> I've now checked GCC sources, and it seems that this warning is
>> unconditional in 4.1.1, whereas it has been fixed and put under
>> -Wconversion in 4.2.0.
>>
>> Yeah, I mostly use C++.
>>
> This is a function of the C++ language,
No, it is not.
> I wouldn't look to turning off the warning as a good thing as C++ is
> supposed to be more type safe than C.
A warning is just a warning. It gives false positives. If it were a
mistake according to the language definition, the compiler would issue
error. It's not an error in C++ to implicitly convert from float to int.
-- Sergei.
More information about the Gcc-help
mailing list