This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC casts short to int



Andrew Haley wrote:
> 
> 
> Right, so you *must* prevent the overflow.  Why do you need the signed
> overflow anyway?  Can't you use unsigned arithmetic?
> 
> Like this:
> 
>   unsigned int c;
>   unsigned short a = 0;
>   unsigned short b = 0;
> 
> 

Thanks Andrew! That totally did the trick.

I didn't need to use signed arithmetic for my purposes, but I can see why
GCC was so stubborn about converting those short variables to integers.

The assembly code now does the two shifts that I wanted to see.

-- 
View this message in context: http://www.nabble.com/GCC-casts-short-to-int-tp24203223p24204360.html
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]