Why does data type conversion not raise an error?

Hi, I have this code:

void main(void)
{ data unsigned char a = 0; data unsigned char b = 0; data unsigned int c = 1000;

b = c;

while(1) { a+= 1; }
}

And it compiles with no errors or warnings. Why is this? Why does it not raise an error because the 16-bit value c is being stored in the 8-bit value b? The Intpromote is turned off, so that is not it.

Yours, confused.

Robbie Martin.

Parents
  • Thank you for the comments that have appeared. I had to ask this question on behalf of a team that I support (really), and the answers have given me a better insight into the C standard. The question was raised because we have a static code analyser which did raise a warning, whereas the compiler didn't.

    I will pass these responses back to the engineer who raised the original query.

    Robbie.

Reply
  • Thank you for the comments that have appeared. I had to ask this question on behalf of a team that I support (really), and the answers have given me a better insight into the C standard. The question was raised because we have a static code analyser which did raise a warning, whereas the compiler didn't.

    I will pass these responses back to the engineer who raised the original query.

    Robbie.

Children
More questions in this forum