[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?
From: |
J.C. Wren |
Subject: |
Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char? |
Date: |
Tue, 23 Dec 2003 13:32:15 -0500 |
User-agent: |
KMail/1.5.4 |
I missed that paragraph. I went back and re-read the section, and the
results now make sense. I still don't like it, but at least the behavior has
been clearly explained.
It would still be nice if the register tracking was smart enough to
realize
that the results are never being used on the high byte, and optimized those
out, though.
Thanks,
--jc
On Tuesday 23 December 2003 13:12 pm, David Gay wrote:
> J.C. Wren wrote:
> > I rewrote the ?: slightly differently, so it's treated more like
> > if/else. It produces the same code as the if() version. The second
> > version (or more correctly, original version) of ?: is not optimizing
> > correctly, based on my interpetation of the grammar. Considering that
> > every thing is cast, I am unclear as to why it thinks it needs to promote
> > to ints for the intermediate results.
>
> Because the C standard says it must. To quote from section 6.5.15,
> conditional operator:
> If both the second and third operands have arithmetic
> type, the type that the usual arithmetic conversions would
> yield if applied to those two operands is the type of the
> result. If both the operands have structure or union type,
> the result has that type. If both operands have void type,
> the result has void type.
>
> Where the usual arithmetic conversions include the rule that anything
> smaller than int is promoted to int.
>
> David Gay
> address@hidden
- [avr-gcc-list] Why is gcc promoting on an unsigned char?, (continued)
- [avr-gcc-list] Why is gcc promoting on an unsigned char?, J.C. Wren, 2003/12/23
- [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, J.C. Wren, 2003/12/23
- RE: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, Rune Christensen, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, J.C. Wren, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, Jörgen Birkler, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, Neil Johnson, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, J.C. Wren, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, Neil Johnson, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, J.C. Wren, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?, David Gay, 2003/12/23
- Re: [avr-gcc-list] Re: Why is gcc promoting on an unsigned char?,
J.C. Wren <=