This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-04-18


82. Definition of "using" a constant expression

Section: 6.3  [basic.def.odr]     Status: dup     Submitter: Bill Gibbons     Date: 31 Dec 1998

The wording in 6.3 [basic.def.odr] paragraph 2 about "potentially evaluated" is incomplete. It does not distinguish between expressions which are used as "integral constant expressions" and those which are not; nor does it distinguish between uses in which an objects address is taken and those in which it is not. (A suitable definition of "address taken" could be written without actually saying "address".)

Currently the definition of "use" has two parts (part (a) and (d) below); but in practice there are two more kinds of "use" as in (b) and (c):

  1. Use in "sizeof" or a non-polymorphic "typeid". Neither the value nor the address is really used. No definition is needed at all.
  2. Use as an integral constant expression. Only the value is used. A static data member with its initializer given in the class need not have a namespace-scope definition.
  3. Use which requires the value, which is known at compile time because the object is const, of integral or enum type, and initialized with an integral constant expression. Only the value need be used, but an implementation is not required to use the value from the initializer; it might access the object. So in the original example, the namespace-scope definition is required even though most compilers will not require it.
  4. All other uses require that the object actually exist because its address will be taken implicitly or explicitly.
We discussed (b) and decided that the namespace-scope definition was not needed, but the wording did not make it into the standard.

I don't think we discussed (c).

Rationale (04/99): The substantive part of this issue is covered by Core issue 48