On Thu, 15 Aug 2024, Paul Koning via cctalk wrote:
>> I don't know about the VAX,but my gripe is
the x86 and the 68000 don't
>> automaticaly promote smaller data types to larger ones. What little
>> programming I have done was in C never cared about that detail.
>> Now I can see way it is hard to generate good code in C when all the
>> CPU's are brain dead in that aspect.
It is not the hardware that is at fault.
If anybody else is to blame, it is the compiler.
int8 A = -1;
uint8 B = 255;
/* Those have the same bit pattern! */
int16 X;
int16 Y;
X = A;
Y = B;
will X and Y have a bit patterns of 0000 0000 1111 1111, or 1111 1111 1111 1111
If you expect them to be "promoted", you are giving ambiguous instructions
to the compiler.
The CPU isn't ever going to know.
THAT is why explicit typecasting is the way to go.
--
Grumpy Ol' Fred cisin(a)xenosoft.com