Title
Definition of "using" a constant expression
Status
dup
Section
6.3 [basic.def.odr]
Submitter
Bill Gibbons

Created on 1998-12-31.00:00:00 last changed 306 months ago

Messages

Date: 1999-04-15.00:00:00

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

Date: 2022-09-25.18:08:42

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

History
Date User Action Args
1999-09-14 00:00:00adminsetmessages: + msg182
1998-12-31 00:00:00admincreate