Constant expressions and cvalues

Moderators: david ward, misra cpp

Post Reply
Posts: 12
Joined: Wed Sep 06, 2017 4:25 pm
Company: Gimpel Software

Constant expressions and cvalues

Post by abgs » Mon Sep 11, 2017 9:05 pm

The description of cvalue expressions in section 6 uses the phrase "constant integral expressions" while citing the C++ standard section on constant expressions which does not contain the quoted phrase. Is "constant integral expressions" intended to say "integral constant expression", or does "constant integral expression" refer to a distinct concept?

Below, under the heading "Constant expressions", rules for "a constant expression" are defined in terms of the value of an integer literal. Not all "constant expressions" are integer values, e.g. the address-of operator can produce a "constant expression" of pointer type (but is not an "integral constant expression"), and it does not make sense to speak an integer literal having a pointer value. Is the use of unqualified "constant expression" here intended to have some missing "integral" qualification, or to continue referring to the "constant integral expressions" used earlier?

"Constant expressions" involving floating point arithmetic are not considered "integral constant expressions" but are "arithmetic constant expressions" (whereas "integral constant expressions" may contain floating literals if they are immediately cast to an integer type). Is an "arithmetic constant expression" that is not an "integral constant expression" considered a "constant integral expression" for the purposes of determining whether an expression is or is not a cvalue? Is an "arithmetic constant expression" considered a "constant expression" [presumably with a missing "integral" somewhere"] for the purposes of the "Constant expressions" heading even though it is not an "integral constant expression"?

misra cpp
Posts: 151
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: Constant expressions and cvalues

Post by misra cpp » Fri Sep 22, 2017 4:22 pm

"constant integral expression" and "integral constant expression" are synonymous

The section on underlying types only relates to integer values - though this not not be sufficiently explained. It will be clarified in the next version
Posted by and on behalf of
the MISRA C++ Working Group

Post Reply

Return to “6.5 Expressions (C++)”