Skip to content

[expr.const] Definition domain fixes for "usable in constant expressions"#8670

Merged
tkoeppe merged 3 commits intocplusplus:mainfrom
hubert-reinterpretcast:UsableInConstantExpressionsFixDomain
May 4, 2026
Merged

[expr.const] Definition domain fixes for "usable in constant expressions"#8670
tkoeppe merged 3 commits intocplusplus:mainfrom
hubert-reinterpretcast:UsableInConstantExpressionsFixDomain

Conversation

@hubert-reinterpretcast
Copy link
Copy Markdown
Member

  • Fix index entries to identify the domains of the definitions
  • Fix wording error that restricted the domain of the definition for variables

Comment thread source/expressions.tex Outdated
Comment thread source/expressions.tex Outdated
$V$'s initializing declaration $D$ is reachable from $P$ and
A variable $V$ is
\defnx{usable in constant expressions}{usable in constant expressions!variable} at a point $P$ if
$V$ is constant-initialized and potentially-constant,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious that the new restriction that $V$ is constant-initialized is editorial. What does this do? Also, doesn't this conclude from the first bullet that $V$ is constexpr or something else?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious that the new restriction that V is constant-initialized is editorial.

That $V$ is constant-initialized is, in the strict reading of the old wording, a prerequisite for the definition to apply.

Also, doesn't this conclude from the first bullet that V is constexpr or something else?

It does not, because in

extern int &r0;
int &r = r0;
constexpr int &r2 = r;

r is potentially-constant and has an initializing declaration reachable from, and in the same translation unit as, the definition of r2.

@eisenwave eisenwave added the P2-Bug Presentational errors and omissions label Dec 19, 2025
@eisenwave
Copy link
Copy Markdown
Member

P2 because we have two identical \defn entries, and that's probably not how those macros should be used.

@wg21bot wg21bot added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Apr 20, 2026
Copy link
Copy Markdown
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good change.

@hubert-reinterpretcast , could you please rebase + force-push?

@hubert-reinterpretcast hubert-reinterpretcast force-pushed the UsableInConstantExpressionsFixDomain branch from 5b65d57 to 5ea9486 Compare May 3, 2026 03:22
@hubert-reinterpretcast
Copy link
Copy Markdown
Member Author

could you please rebase + force-push?

@jensmaurer: done

@jensmaurer jensmaurer removed the needs rebase The pull request needs a git rebase to resolve merge conflicts. label May 3, 2026
@jensmaurer
Copy link
Copy Markdown
Member

@tkoeppe , you had concerns here, so I'll leave the merge to you. We need a squash.

@tkoeppe
Copy link
Copy Markdown
Contributor

tkoeppe commented May 3, 2026

@jensmaurer I don't quite recall -- are you referring to the indexing perhaps, or the normative wording?

@jensmaurer
Copy link
Copy Markdown
Member

jensmaurer commented May 3, 2026

Ah, sorry, I confused the author of the (still open) comment here. @tkoeppe , just go ahead if you feel this is ok.

@tkoeppe tkoeppe merged commit fb2c3e6 into cplusplus:main May 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2-Bug Presentational errors and omissions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants