boostorg / boostorg/random

compile discrete_distribution for 64-bit code

Open
#46 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
42
Forks
76
Avg merge
4d 8h
Merged PRs (30d)
5

Description

When compiling discrete_distribution using MSVC 2010 64-bit compiler, warnings are emitted.
The key warning says:
warning C4267: 'argument' : conversion from 'size_t' to 'int32_t', possible loss of data

Cause of the issue:
In random/discrete_distribution.hpp, at line 507, the expression `_impl.get_weight(i)` tries to convert 'i' (a 'size_t') into 'IntType' (the parameter type of `get_weight()`).
However, 'IntType' is 'int' by default, which causes a conversion from 64-bit to 32-bit in a 64-bit environment.

Suggestions:
At line 499, 'i' is defined as a 'size_t'.
It should be safe to define it as an 'IntType':
`IntType i = 0;`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.