14-04-2017, 02:08 AM
According to MISRA C++ 2008 section 6.5, the underlying type of an integer contant expression is calculated based on its evaluated value. Griven expressions as below:
1. unsgined long v1 = 1UL; //Underlying type of "1UL" is unsigned char.
2. if(1) {//...} //Underlying type if "1" is signed char.
3. if(2000-1999){//...} //Underlying type of expression "2000-1999" is signed char.
Are the undelying type of above expressions correct? Then for the above three cases, there should be implicit cases as following:
1. unsigned char => unsigned long
2. signed char => int
3. signed char => int
Correct?
1. unsgined long v1 = 1UL; //Underlying type of "1UL" is unsigned char.
2. if(1) {//...} //Underlying type if "1" is signed char.
3. if(2000-1999){//...} //Underlying type of expression "2000-1999" is signed char.
Are the undelying type of above expressions correct? Then for the above three cases, there should be implicit cases as following:
1. unsigned char => unsigned long
2. signed char => int
3. signed char => int
Correct?
<t></t>