30-03-2017, 07:27 AM
You are correct to say that the code is not-compliant.
The C standard type is "signed long", since it is the result of a unary negation on a literal whose type is "signed long".
The essential type and C standard type of an expression may only differ if the C standard type is "int" or "unsigned int". This is not the situation, so the essential type is also "signed long".
Using INT_MIN from the limits.h will return an expression with the correct value and "signed int" type.
The C standard type is "signed long", since it is the result of a unary negation on a literal whose type is "signed long".
The essential type and C standard type of an expression may only differ if the C standard type is "int" or "unsigned int". This is not the situation, so the essential type is also "signed long".
Using INT_MIN from the limits.h will return an expression with the correct value and "signed int" type.
Posted by and on behalf of the MISRA C Working Group