cplusplus / cplusplus/draft

[atomics.types.operations]/[atomics.wait] Clarify the behavior of `constexpr` atomic `wait()`

Open
#9,298 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cwg not-editorial P3-Other
Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

I find it very odd that https://eel.is/c++draft/atomics.types.operations#lib:wait,atomic doesn't specify what happens during constant evaluation.

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3309r3.html#wait argues that wait() during compile time would exceed implementation limits, but there is no implementation limit that's clearly exceeded here. Why shouldn't wait() be allowed to deadlock the compiler frontend? "system clock time" or "execution steps" are not limits in [implimits] after all, and even if were, that's not a normative index.

Perhaps an argument against deadlocking the frontend is that https://eel.is/c++draft/intro.progress#1 specifies that any thread (presumably including the compiler frontend thread for constant evaluation) will make progress eventually. Core language UB is not a constant expression, and that includes [intro], so I guess that makes the call to wait() immediately invalid.

A possible way to clarify it is to say that atomic waiting operations are not constant expressions (either normatively or as a note), to include atomic_flag_wait, atomic_wait, atomic::wait, atomic_ref::wait, etc. in one fell swoop.

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

Start by reading the [atomics.types.operations]/[atomics.wait] wording, the linked eel.is clauses, and WG21 paper P3309R3. Determine whether the standard should explicitly exclude atomic waiting operations from constant expressions and whether the listed wait APIs can be covered together; done means a reviewed, normative clarification or agreed rationale.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.