Significant deficiency in C

Andrew Koenig ark at alice.UucP
Tue Sep 30 22:46:44 AEST 1986

> Inspecting critical loops in the generated code, I was shocked to find that the
> compiler was doing what it could to make things fast, but it was hindered by
> the requirement that char types be promoted to int before being used in an
> expression.  The 8088 CPU has 16-bit registers that are made up of pairs of
> 8-bit registers and each 8-bit register can be separately used for 8-bit
> operations, making character-oriented code extremely efficient.  But the
> compiler was forced to treat such code as int-oriented code (ints being 16 bits
> in this implementation).  Hand-crafted assembly code, where the programmer
> knows whether or not 16 bits will be ultimately needed, isn't similarly
> restricted. 

One would think that for many char operations it is possible for
the compiler to figure out that doing it in 8 bits and expanding to
16 at the end only if necessary will give the same result as expanding
to 16 bits immediately.

Can you give us some examples of code that you think would be
impossible to get right without changing the rules?

More information about the Comp.lang.c mailing list