Skip to content

Commit 137297a

Browse files
committed
fix: explicitly cast rmp::AnnealingStrategy::random_'s seed to 32-bit
`rmp::AnnealingStrategy::random_` is `std::mt19937` which is 32-bit: https://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine.html This in turn causes the constructor for `AnnealingStrategy` to be ill-formed according to the C++17 standard: > List-initialization of an object or reference of type T is defined as follows: > ... > (3.7) Otherwise, if T is a class type, constructors are considered. The applicable constructors are enumerated and the best one is chosen through overload resolution (16.3, 16.3.1.7). If a narrowing conversion (see below) is required to convert any of the arguments, the program is ill-formed. As the seed is `uint64_t` and `mt19937` uses `uint32_t`, this is a narrowing conversion that fails to compile on at least Darwin. This is the solution that probably causes the least amount of surprises. Signed-off-by: Mohamed Gaber <me@donn.website>
1 parent fce81f1 commit 137297a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/rmp/src/annealing_strategy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class AnnealingStrategy : public ResynthesisStrategy
3434
initial_ops_(initial_ops)
3535
{
3636
if (seed) {
37-
random_ = decltype(random_){*seed};
37+
const uint32_t seed_32 = *seed;
38+
random_ = decltype(random_){seed_32};
3839
}
3940
}
4041
void OptimizeDesign(sta::dbSta* sta,

0 commit comments

Comments
 (0)