Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Underlying type of sum of constants
#2
The bottom of the question is whether the last line in the example shown violates rule 5-0-4 although both operands appear to be unsigned:

Code:
namespace {
typedef unsigned short ui16;
const ui16 x = 1U;
const ui16 y = 2U;
const ui16 z = x + y;// violation of rule 5-0-4 without explicitly casting the result (static_cast(x + y))???
}

It would decrease readability as stated on page 55, so i think clarification is important for both developers and tool suppliers.
On page 55 an integer constant expression is said to be made up only of literals.
But the literals (1U and 2U) have already been turned into constants with a different type, so that has to make a difference, right?
Thanks.
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)