Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clarification for underlying type of an integer constant expression
#1
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?
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)