On Sat, Dec 19, 2009 at 5:08 AM, James Carlson <carlsonj at 
workingcode.com>wrote:

> On Dec 18, 2009, at 7:27 PM, Vincent Torri <vincent.torri at gmail.com>
> wrote:
>
>  hey,
>>
>> i have an enum in which a value is set as 1L << 31. suncc reports:
>>
>> warning: integer overflow detected: op "<<"
>>
>> I don't understand as, afaik, an enum is considered as an int and 1 << 31
>> fits in an int. Can someone explain we what is wrong ?
>>
>
> It doesn't fit. A 32-bit int has a range of -2^31 to 2^31-1.  That result
> can't be represented.
>
> 1U<<31 fits in an unsigned int, but 1<<31 doesn't in a signed one.
>
> arg, you're right, i've forgotten the sign

thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.opensolaris.org/pipermail/tools-compilers/attachments/20091219/4a5d04d3/attachment.html>

Reply via email to