Compiler error on <mutex>:304 - by Jorge.Ferreira

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 733222 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 3/25/2012 2:36:21 PM
Access Restriction Public


A compiler error:

1>c:\program files\microsoft visual studio 11.0\vc\include\mutex(304): error C4716: 'std::unique_lock<std::mutex>::try_lock' : must return a value

occurs when compiling the following program:

#include "stdafx.h"
#include <mutex>

std::mutex m;

int _tmain(int argc, _TCHAR* argv[])
	std::unique_lock<std::mutex> lock_a(m, std::defer_lock);
	return 0;

The try_lock method of std::unique_lock must return a value. A possible fix would be:

bool try_lock() _NOEXCEPT
{	// try to lock the mutex
	_Owns = _Pmtx->try_lock();
	return (_Owns);
Sign in to post a comment.
Posted by Microsoft on 3/26/2012 at 3:49 PM

Thanks for reporting this bug. We've already fixed it, and the fix will be available in VC11.

If you have any further questions, feel free to E-mail me at .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by EricLeong [Feedback Moderator] on 3/25/2012 at 11:45 PM
Thank you for submitting feedback on Visual Studio 11 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 3/25/2012 at 2:46 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(