Skip to content

[expr.const] Unclear use of constexpr-referenceable and constexpr-representable due to missing the point #8663

@brevzin

Description

@brevzin

In [expr.const] we define:

  • p3: constexpr-referenceable at a point P
  • p4: constexpr-representable at a point P (defined in terms of constexpr-referenceable at P)

However, there are other uses that don't explicitly use a point, the point is simply implied. I think it would add a lot of clarity if we simply explicitly stated a point.


The example in p3 is:

struct A {
  int m;
  const int& r;
};
void f() {
  static int sx;
  thread_local int tx;                  // tx is never constexpr-referenceable
  int ax;
  A aa = {1, 2};
  static A sa = {3, 4};
  // The objects sx, ax, and aa.m, sa.m, and the temporaries to which aa.r and sa.r are bound, are constexpr-referenceable.
  auto lambda = [] {
    int ay;
    // The objects sx, sa.m, and ay (but not ax or aa), and the
    // temporary to which sa.r is bound, are constexpr-referenceable.
  };
}

The first comment can say something like "tx is not constexpr-referenceable at any point". The second and third can be changed to something like "The objects xs, ax, [...] are constexpr-referenceable at this point". Alternatively, the example could have comments like // P1 and // P2 and then have text beneath the example saying something like "The objects xs, ax, and aa.m, and the temporary to which sa.r is bound, are constexpr-referenceable at points P1 and P2. The objects ax, aa, and the temporary to which aa.r is bound is constexpr-referenceable at point P1 but not P2." Something in that vein.


One of the subbullets in p5 is:

immediately after the initializing declaration of v, the object or reference x declared by v is constexpr-representable, and

Which could be flipped to say

the object or reference x declared by v is constexpr-representable at the point immediately after the initializing declaration of v, and

Just to follow the framing of the definition. Also just reads better anyway I think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions