I am learning C, and integer promotion and the term demotion is new to me. I have read in the C Standard (C17) about the C type conversions and the integer promotion, but I don't know how to identify an integer promotion, and I don't know anything about demotion.
For example, if I have these lines of code:
...
unsigned char x;
int y;
long int z;
int aux; //Auxiliary variable
x = 'c';
y = 1;
z = 2;
aux = x;
aux = y;
aux = z;
aux = x + y; // ZX
aux = y + z;
...
Where do I have integer promotion? Because from what I know, in the line of code commented with ZX, I have integer promotion, but only in that line, but I'm not sure; can you clarify it for me?
And can you give me examples of when demotion exists? Because the C Standard does not clarify.
Definitely not my specialty, but let me try:
I try not to over-rely on promotion rules when programming.