• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Spurious warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Spurious warnings


  • Subject: Re: Spurious warnings
  • From: "Clark Cox" <email@hidden>
  • Date: Tue, 22 Jul 2008 06:47:20 -0700

On Tue, Jul 22, 2008 at 2:09 AM, Jan E. Schotsman <email@hidden> wrote:
>
> On Jul 22, 2008, at 10:41 AM, Matt Gough wrote:
>
>> But as the original subject of this thread says, this is surely a spurious
>> warning, as he is passing floats into a function that takes floats and only
>> uses the parameters as floats in the implementation.
>>
>> I could understand it if he was doing this with his parameters:
>>
>> drawRect = CGRectMake(  0.0,    // Double -> float
>>                        1,      // integer -> float
>>                        shapeBounds.size.width * 2.0f,  // Double temporary
>> -> float
>>                        shapeBounds.size.height + 0.5   // Ditto
>>                        );
>>
>> I haven't checked, but maybe the ABI wants floating point params to always
>> be doubles and this warning is really telling you this?
>
> In case of a double temporary I still think the warning is incorrect as I
> have chosen to work in 32-bit precision.

The warning is not incorrect, and is behaving exactly as advertised.

> IMHO compiler warnings are not meant to say "why don't you use doubles only
> as the compiler converts your floats to doubles anyway"?

That is not what the warning is saying. The -Wconversion warning was
created to help those moving from pre-standard C to standard C. Before
standard C, there was no such thing as a function prototype, so *all*
parameters to functions went through default arithmetic promotions.
That means that it was impossible to have a function take parameters
(for instance) of type float, short, or char, as they would always be
promoted to double, int and int respectively.

This warning was to make sure that people knew what they were doing
when they passed parameters that were incompatible with these default
promotions. Nothing more, nothing less.

--
Clark S. Cox III
email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Spurious warnings (From: "Jan E. Schotsman" <email@hidden>)
 >Re: Spurious warnings (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Spurious warnings (From: Matt Gough <email@hidden>)
 >Re: Spurious warnings (From: "Jan E. Schotsman" <email@hidden>)

  • Prev by Date: Re: Using NSPipe with NSStream?
  • Next by Date: type-punning to incomplete type might break strict-aliasing rules
  • Previous by thread: Re: Spurious warnings
  • Next by thread: Re: Spurious warnings
  • Index(es):
    • Date
    • Thread