[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Urgent Queries about AVR-GCC

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Urgent Queries about AVR-GCC
Date: Wed, 4 Jun 2003 10:35:25 +0200 (MET DST)

Neil Johnson <address@hidden> wrote:

>> This has to be checked against the C standard (Jörg, do you know if
>> this applies?). Just because Borland C++ 5.5 does one thing,
>> doesn't mean that it's using ISO C only.

> I've just checked the ANSI C standard (1990 edition) and as far as I
> understand it, there is no requirement to promote the controlling
> expression to "int".  What the standard does say (section
> is that the type of the controlling expression must be of integral
> type, ...

No longer in the current standard (or the draft i've got):

`` The switch statement


1 The controlling expression of a switch statement shall have integer


5 The integer promotions are performed on the controlling
  expression. The constant expression in each case label is converted
  to the promoted type of the controlling expression.  [...]''

Of course, if the results are identical, it seems to be possible to
skip the high byte comparision as an optimization.  For most
architectures gcc is compiling code for, however it just makes no
sense to do this.  On an IA32 CPU, you need a register anyway, and
comparision of a 32-bit register against another 32-bit register has
the same execution speed and code size (sometimes even a better one)
than restricting this to 8 bits of that register.

J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]