Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

compile discrete_distribution for 64-bit code

Open
#46 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp
Domain
backend

Research direction

Start in random/discrete_distribution.hpp around lines 499 and 507, and inspect how the loop index is passed to _impl.get_weight(). Compile the component with the MSVC 2010 64-bit compiler; done means the reported size_t-to-int32_t warning is no longer emitted.

Written by the indexing model from the issue text.

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;.

Dominant language
C++
Stars
42
Forks
76
Avg merge
3d 22h
Merged PRs (30d)
6

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/random

All issues in boostorg/random

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.