cplusplus / cplusplus/draft

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

Open
#8,663 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the [expr.const] source text and review paragraphs p3–p5 and the accompanying example. Make the implied points explicit wherever constexpr-referenceable or constexpr-representable is used, then verify that the wording consistently identifies the relevant point and preserves the example’s intended distinctions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, tex
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.