gnustep-dev
[Top][All Lists]
Advanced

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

Re: Overflow in constant conversion


From: Wolfgang Lux
Subject: Re: Overflow in constant conversion
Date: Mon, 8 Apr 2013 18:18:08 +0200

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).

Wolfgang




reply via email to

[Prev in Thread] Current Thread [Next in Thread]