cplusplus / cplusplus/draft

[atomic.ref.generic] Issues regarding P3323R1

Open
#7,556 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Issue 1: The paper adds this paragraph to multiple sections:

The program is ill-formed if is_always_lock_free is false and is_volatile_v<T> is true.

For the main template, it is OK, but there are issues with the (partial) specializations:

  • For the integral and floating-point specializations, there is no template parameter T, so is_volatile_v<T> cannot be well-formed.
  • For the pointer partial specialization, T refers to the pointed-to type, testing whether it is volatile is definitely not the intention of the author.

Issue 2: The paper adds this paragraph to [atomics.ref.pointer]:

There are specializations of the atomic_ref class template for all pointer-to-object types. For each such
type pointer-type, the specialization atomic_ref<pointer-type> provides additional atomic operations
appropriate to pointer types.

This paragraph seems to identify the pointer specializations as explicit (full) specializations, but it is impossible to enumerate all pointer(-to-object) types. The wording also implies that pointer-to-function types should match the main template, which is currently not the case. Currently, pointer-to-function types match the partial specialization, and such specializations can invoke the member functions that are also provided in the main template (the additional operations are guarded by [atomics.ref.pointer] p6). We should not change this.

We should keep the partial specialization, and we need to redefine atomic_ref<pointer-type> to make use of the template parameter T.

Suggested resolution (I can file a PR if CWG agrees with this direction):

  • [atomics.ref.int] p2: Replace is_volatile_v<T> with is_volatile_v<integral-type>.
  • [atomics.ref.float] p2: Replace is_volatile_v<T> with is_volatile_v<floating-point-type>.
  • [atomics.ref.pointer] p1: Replace paragraph with:

There are partial specializations of the atomic_ref class template for all pointer types. For each type-id pointer-type among T*, T* const, T* volatile, and T* const volatile, the partial specialization atomic_ref<pointer-type> provides additional atomic operations appropriate to pointer-to-object types.

  • [atomics.ref.pointer] p2: Replace is_volatile_v<T> with is_volatile_v<pointer-type>.

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

Search the draft for [atomics.ref.int], [atomics.ref.float], and [atomics.ref.pointer], then compare the existing paragraphs with the suggested resolution. Done means correcting the is_volatile_v references and describing the pointer cases as partial specializations without changing the stated pointer-to-function behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.