GCC casts short to int

Andrew Haley aph@redhat.com
Thu Jun 25 13:50:00 GMT 2009


John (Eljay) Love-Jensen wrote:
> Hi Leonitis,
> 
>> How can I instruct GCC (in the code) to do this?
> 
> The production is:
> 
> (short) * (short) ==> (int)
> 
> If you want that to be a short:
> 
> (short)((short) * (short)) ==> (short)
> 
> So try this:
> 
> c += (short)(a * b);

It's still an integer overflow.

Andrew.



More information about the Gcc-help mailing list