[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Overflow in constant conversion
From: |
Richard Frith-Macdonald |
Subject: |
Re: Overflow in constant conversion |
Date: |
Mon, 8 Apr 2013 17:24:51 +0100 |
On 8 Apr 2013, at 17:18, Wolfgang Lux wrote:
> Wolfgang Lux wrote:
>
>> I just noticed the following warning while compiling NSCalendar.m:
>>
>> NSCalendar.m: In function '-[NSCalendar initWithCalendarIdentifier:]':
>> NSCalendar.m:264:3: warning: overflow in implicit constant conversion
>> [-Woverflow]
>> NSCalendar.m:265:3: warning: overflow in implicit constant conversion
>> [-Woverflow]
>>
>> Looking at the source, the code assigns NSNotFound to the members
>> firstWeekday and minimumDaysInFirstWeek. Both members are declared as
>> int32_t, which means that NSNotFound will get truncated to -1 on a 64-bit
>> target. This means that the later checks whether the member contain
>> NSNotFound will always fail on a 64-bit target. What would be wrong with
>> using -1 instead of NSNotFound in the first place?
>
> or changing the type of both members back to NSInteger, as it happened to be
> before r36441. (Looking at the commit log, the change to int32_t looks
> unrelated anyway).
Sounds right ... I did that. Will check it on a 64bit system when I get the
chance.