Andreas Schwab wrote:-
> Andrew Pinski <[EMAIL PROTECTED]> writes:
>
> > sorry wrong number, I had meant 32769.
> > if (foo (32769) != 1)
> > abort ();
>
> I think with 16 bit ints you should get 0 here, since (int)32769 ==
> -32767, which is less than 32767.
int foo(unsigned short x)
{
On Sun, Nov 27, 2005 at 12:25:28PM -0500, Andrew Pinski wrote:
> Actually I am not seeing that but instead I am seeing the subtraction done in
> short and not in int (which is far as I can tell and remember reading the
> promotion rules in C doing).
You're wrong about the C promotion rules.
r~
Andrew Pinski <[EMAIL PROTECTED]> writes:
> sorry wrong number, I had meant 32769.
> if (foo (32769) != 1)
> abort ();
I think with 16 bit ints you should get 0 here, since (int)32769 ==
-32767, which is less than 32767.
Andreas.
--
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux
>
> Andrew Pinski <[EMAIL PROTECTED]> writes:
>
> > If we look at this testcase, we have a function like:
> > int foo(unsigned short x)
> > {
> > unsigned short y;
> > y = x > 32767 ? x - 32768 : 0;
> > return y;
> > }
> >
> >
> > x is promoted to a signed int by the front-end as the type
>
>
> Andrew Pinski <[EMAIL PROTECTED]> writes:
>
> > x is promoted to a signed int by the front-end as the type
> > of 32768 is signed. So when we pass 65535 to foo (like in the testcase),
> > we get some large negative number for (signed int)x
>
> I don't see how you can get a large negative nu
Andrew Pinski <[EMAIL PROTECTED]> writes:
> If we look at this testcase, we have a function like:
> int foo(unsigned short x)
> {
> unsigned short y;
> y = x > 32767 ? x - 32768 : 0;
> return y;
> }
>
>
> x is promoted to a signed int by the front-end as the type
> of 32768 is signed. So wh
Andrew Pinski <[EMAIL PROTECTED]> writes:
> x is promoted to a signed int by the front-end as the type
> of 32768 is signed. So when we pass 65535 to foo (like in the testcase),
> we get some large negative number for (signed int)x
I don't see how you can get a large negative number for that. W
If we look at this testcase, we have a function like:
int foo(unsigned short x)
{
unsigned short y;
y = x > 32767 ? x - 32768 : 0;
return y;
}
x is promoted to a signed int by the front-end as the type
of 32768 is signed. So when we pass 65535 to foo (like in the testcase),
we get some lar