>You might be right about this specific processor, but I'll bet that it (32 bit architecture) played a role in the decision.
I don't so, you probably would loose this bet. It only matters that the size of an int is bigger than the size of a char, and that's the case on most architectures (not on all).
> Not all compilers handle the promotion the same.
All ANSI-C compilers handle the promotion the same.
> If the compiler recognizes the operation is on a unsigned char then it may not be promoted to
> the architecture int size as you suggest.
It is per language always promoted. Always.
This does not mean however that any compiler will end up generating code which does use int's in the generated code, if the result is the same as if the operation was done with smaller types, then all compilers I know will use smaller types if this is preferable.
From a language point of view this is already an optimization.
> Try examining disassembled code from other vendors and you will observe what I am talking about.
The warning is not about the generated code at all, it is about the types being used. Looking at the generated code therefore does not show the issue the compiler warns about.
> If this is a convenience, optimization or a departure from the 'C' standard I can't say
It's neither of those. The compiler simply states that an int is assigned to a unsigned char.
>, but the result is the team of software developers have come to rely on it, and now we will be forced to edit the code with a
> bunch of casting. Anyhow, your suggestion in your first post was on target and casting the result of the | worked,
> this is why I responded that a solution had been found.
I think issue you have is that the compiler warns (technically correctly) about something which he could know that it is not an issue in this case after all. While it is correct that an int gets assigned to a unsigned char, the compiler could deduce that in this particular case all of the bits of the int which do not fit into the destinations unsigned char are indeed 0's. So the assignment cuts the type, but it does not cut any possible value.
When I tried the sample with the CF V1 compiler in mcu 10, I did not get the warning, maybe this unnecessary warning case has already been addressed in the compiler :smileyhappy:
Daniel