Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Essential types of constant variables
#2
(30-07-2021, 10:27 PM)LordMordac Wrote: I'm having a disagreement with my tool vendor over the essential types of constant variables.
Code:
uint32_t v1 = 1U;
const uint32_t v2 = 1U;
static const uint32_t v3 = 1U;
constexpr uint32_t v4 = 1U;

My interpretation of the spec is that all the identifiers (v1, v2, v3 and v4) have uint32_t essential type.

My tool vendor's interpretation is that v1 has a uint32_t essential type. While v2, v3 and v4 have a uint8_t essential type.  (I don't have any insight into their reasoning)

Clarification on this issue would be much appreciated.

The core of the disagreement revolves around this:
-----------------------------------------------------------------------------------------------------------------
The underlying type of an integer constant expression is therefore defined as follows:
1. If the actual type of the expression is signed integral, the underlying type is defined as the smallest signed type integer type that is capable of representing the data.
2. If the actual type of the expression is unsigned integral, the underlying type is defined as the smallest unsigned type integer type that is capable of representing the data.
3. In all other circumstances, the underlying type of the expression is defined as being the same actual type.
-----------------------------------------------------------------------------------------------------------------

I believe that all four instances fall into category 3.  The tool vendor engineer believes v2, v3, and v4 fall into category 2.
Reply


Messages In This Thread
RE: Essential types of constant variables - by LordMordac - 02-08-2021, 04:38 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)