From 87477f5023152ba8a7f745c72e14bb95d81dee82 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Mon, 6 Nov 2017 13:12:44 -0700 Subject: [PATCH] Work around problem on msvc-12/14 in release mode. --- include/boost/random/linear_congruential.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/random/linear_congruential.hpp b/include/boost/random/linear_congruential.hpp index de3a1d0749..22ade3f3db 100644 --- a/include/boost/random/linear_congruential.hpp +++ b/include/boost/random/linear_congruential.hpp @@ -124,8 +124,12 @@ class linear_congruential_engine * distinct seeds in the range [1,m) will leave the generator in distinct * states. If c is not zero, the range is [0,m). */ - BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(linear_congruential_engine, IntType, x0) + BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(linear_congruential_engine, IntType, x0_) { + // Work around a msvc 12/14 optimizer bug, which causes + // the line _x = 1 to run unconditionally sometimes. + // Creating a local copy seems to make it work. + IntType x0 = x0_; // wrap _x if it doesn't fit in the destination if(modulus == 0) { _x = x0;