generate_int_float_pair() and uint64_t engines
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
Research direction
Inspect random/detail/int_float_pair.hpp around lines 65-77, especially the assignments to bucket from generate_one_digit(). Reproduce the MSVC 2010 warning if available, then verify that the uint64_t engine path no longer produces the reported conversion warnings while preserving the existing calculations.
Written by the indexing model from the issue text.
Description
When a random engine with a 'result_type' of 'uint64_t' is fed to exponential_distribution::operator()(), MSVC 2010 generates lots of warnings.
The key warning complains that:
warning C4244: '=' : conversion from 'base_unsigned' to 'int', possible loss of data.
Cause of the issue:
In random/detail/int_float_pair.hpp, at line 65, a local variable 'bucket' is defined as an 'int'.
At line 68, 'generate_one_digit()' returns a value of type 'base_unsigned' (actually 'uint64_t').
At line 69, the value joins certain calculation, and the result value of type 'uint64_t' is assigned to 'bucket', which is a 64-bit to 32-bit conversion, and issues the warning.
At line 77, there is the same problem.
Suggestions:
At line 67, there is a 'for' loop. However, if 'base_unsigned' has 64 digits, 'm' is 64, and the loop will never run.
At line 69, it should be safe to cast the result of the calculation into 'int' before it is assigned to 'bucket'.
i.e., bucket = static_cast<int>((bucket << m) | u);
At line 77, bucket = static_cast<int>((bucket << (w%m)) | (mask & u));
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/random
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Documentation
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100