gnustep-dev
[Top][All Lists]
Advanced

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

Overflow in constant conversion


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

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?

Wolfgang




reply via email to

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