This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Dup status.

905. Mutex specification questions

Section: 33.6.4.2.2 [thread.mutex.class] Status: Dup Submitter: Herb Sutter Opened: 2008-09-18 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [thread.mutex.class].

View all issues with Dup status.

Duplicate of: 893

Discussion:

A few questions on the current WP, N2723:

33.6.4 [thread.mutex.requirements]/24 says an expression mut.unlock() "Throws: Nothing." I'm assuming that, per 99 [res.on.required], errors that violate the precondition "The calling thread shall own the mutex" opens the door for throwing an exception anyway, such as to report unbalanced unlock operations and unlocking from a thread that does not have ownership. Right?

33.6.4.2.2 [thread.mutex.class]/3 (actually numbered paragraph "27" in the WP; this is just a typo I think) says

The behavior of a program is undefined if:

As already discussed, I think the second bullet should be removed, and such a lock() or try_lock() should fail with an exception or returning false, respectively.

A potential addition to the list would be

but without that the status quo text endorses the technique of the program logically transferring ownership of a mutex to another thread with correctness enforced by programming discipline. Was that intended?

[ Summit: ]

Two resolutions: "not a defect" and "duplicate", as follows:

Proposed resolution: