Re: How to turn this warning off?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tom St Denis <tstdenis@xxxxxxxxxxxxxxxx> writes:
> Sergei Organov wrote:
>> Tom St Denis <tstdenis@xxxxxxxxxxxxxxxx> 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.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux