Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock tag types are defined twice, once incorrectly #7074

Open
Quuxplusone opened this issue Jun 25, 2024 · 2 comments
Open

Lock tag types are defined twice, once incorrectly #7074

Quuxplusone opened this issue Jun 25, 2024 · 2 comments
Labels
lwg Issue must be reviewed by LWG.

Comments

@Quuxplusone
Copy link
Contributor

https://eel.is/c++draft/thread#lock.general-2 says:

Some lock constructors take tag types which describe what should be done with the lockable object during the lock's construction.

namespace std {
  struct defer_lock_t  { };     // do not acquire ownership of the mutex
  struct try_to_lock_t { };     // try to acquire ownership of the mutex
                                // without blocking
  struct adopt_lock_t  { };     // assume the calling thread has already
                                // obtained mutex ownership and manage it

  inline constexpr defer_lock_t   defer_lock { };
  inline constexpr try_to_lock_t  try_to_lock { };
  inline constexpr adopt_lock_t   adopt_lock { };
}

But this isn't the actual correct definition of defer_lock_t et al.; those are normatively defined further down in
https://eel.is/c++draft/thread#mutex.syn as having explicit default constructors.

struct defer_lock_t { explicit defer_lock_t() = default; };
struct try_to_lock_t { explicit try_to_lock_t() = default; };
struct adopt_lock_t { explicit adopt_lock_t() = default; };

inline constexpr defer_lock_t  defer_lock { };
inline constexpr try_to_lock_t try_to_lock { };
inline constexpr adopt_lock_t  adopt_lock { };

IMHO we should figure out a way to strike the first (non-normative?) definitions entirely. At worst, the first definitions should be updated to match the correct normative definitions, so that nobody gets confused.

@jensmaurer
Copy link
Member

Please submit an LWG issue; the redundancy should be removed, but there's a lot of LWG discretion involved on what exactly the result should look like.

@jensmaurer jensmaurer added the lwg Issue must be reviewed by LWG. label Jun 25, 2024
@frederick-vs-ja
Copy link
Contributor

I think the decision on explicit default constructors is already made in LWG2510.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lwg Issue must be reviewed by LWG.
Projects
None yet
Development

No branches or pull requests

3 participants