Significant deficiency in C

karl at haddock karl at haddock
Fri Oct 3 00:33:00 AEST 1986

00R0DHESI%bsu.cs at CSNET-RELAY.ARPA (Rahul Dhesi) writes:
>I think [char to int promotion] is a significant deficiency in C.  Is ANSI
>doing anything to eliminate this or decrease its effect?

I doubt it.  Too many programs depend on it.

>Considering that [most] UNIX tools do text processing in 7-bit units, ...

But if they use getchar(), they have to declare the variable "int" anyway.

However, a compiler is free to use 8-bit arithmetic if it can determine that
the result will be the same (e.g. char2 = char0 + char1); I think more work
needs to be done in this area.  (Of course, there will always be cases where
it lacks the information to perform the optimization.)

Karl W. Z. Heuer (ima!haddock!karl or karl at, The Walking Lint
P.S. I just tried c2=c0+c1 on the vax; it did cvtbl, cvtbl, addl2, cvtbl, and
cvtlb.  This sort of slop encourages programmers to declare everything "int".

More information about the Comp.lang.c mailing list