Full name of submitter (unless configured in github; will be published with the issue):
Reference (section label): [expr.const.core]
Prior discussion: cplusplus/draft#9298
Issue description
[atomics.types.operations] specifies that std::atomic<T>::wait is constexpr and that it blocks the thread if the given value is equal to the current value of the object. Other atomic waiting operations ([atomics.wait]) can also block, such as std::atomic_flag::wait.
P3309R3 argues that blocking the thread is not a constant expression because it exceeds implementation limits, but it is unclear which (if any) implementation limits are exceeded by blocking. One might also argue that blocking the thread violates the forward progress guarantee ([intro.progress]), which is undefined behavior and thus not a core constant expression, but this explanation is contrived.
Suggested resolution
Add a bullet to [expr.const.core] paragraph 2:
An expression E is a core constant expression unless the evaluation of E,
following the rules of the abstract machine ([intro.execution]),
would evaluate one of the following:
- ...
- an invocation of the va_arg macro ([cstdarg.syn]);
+ - an operation that blocks the thread of execution ([defns.block]);
- a non-constant library call ([defns.nonconst.libcall]); or
- ...
Full name of submitter (unless configured in github; will be published with the issue):
Reference (section label): [expr.const.core]
Prior discussion: cplusplus/draft#9298
Issue description
[atomics.types.operations] specifies that
std::atomic<T>::waitisconstexprand that it blocks the thread if the given value is equal to the current value of the object. Other atomic waiting operations ([atomics.wait]) can also block, such asstd::atomic_flag::wait.P3309R3 argues that blocking the thread is not a constant expression because it exceeds implementation limits, but it is unclear which (if any) implementation limits are exceeded by blocking. One might also argue that blocking the thread violates the forward progress guarantee ([intro.progress]), which is undefined behavior and thus not a core constant expression, but this explanation is contrived.
Suggested resolution
Add a bullet to [expr.const.core] paragraph 2:
An expression E is a core constant expression unless the evaluation of E, following the rules of the abstract machine ([intro.execution]), would evaluate one of the following: - ... - an invocation of the va_arg macro ([cstdarg.syn]); + - an operation that blocks the thread of execution ([defns.block]); - a non-constant library call ([defns.nonconst.libcall]); or - ...