Debug error occured when setting seed to 0 using std::mt19937 - by onlyForBugReport

Status : 


Sign in
to vote
ID 776456 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/14/2013 12:13:52 AM
Access Restriction Public


#include <random>
void main(){
	std::mt19937 random;

The code above will cause an debug error in debug mode  while in release mode all things works well.
And random.seed(1) works well even in debug mode. And it will produce the same result as boost package.
Think there's some assertion logic wrong in MS edition of the random header file.
Just find the code below in <random> which is wrong:
	_RNG_ASSERT(0 < _X0,
			"invalid argument for mersenne_twister::seed");

The "<" should be "<=" 
Sign in to post a comment.
Posted by Microsoft on 4/29/2014 at 12:31 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from:
Posted by Microsoft on 2/11/2013 at 4:09 PM

Thanks for reporting this bug. We've fixed it, and the fix will be available in VC12. (Our version numbers are: VC8 = VS 2005, VC9 = VS 2008, VC10 = VS 2010, VC11 = VS 2012.)

I fixed all of <random>'s engines to accept 0 seeds and behave as required by the Standard.

Note: Connect doesn't notify me about comments. If you have any further questions, please E-mail me.

Stephan T. Lavavej
Senior Developer - Visual C++ Libraries
Posted by Microsoft on 1/14/2013 at 12:47 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.