Skip to content

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

Description

@eisenwave

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" is not a limit in [implimits] after all, and even if it was, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3-OtherTriaged issue not in P1 or P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions