Skip to content

Fix hang when a floating point value is too big for den_size - #720

Merged
kris-jusiak merged 1 commit into
boost-ext:masterfrom
r3wretrhy:fix/den-size-large-values
Oct 20, 2026
Merged

kris-jusiak merged 1 commit into
boost-ext:masterfrom
r3wretrhy:fix/den-size-large-values

Conversation

@r3wretrhy

Copy link
Copy Markdown
Contributor

Problem:

  • expect(a == _d(1.e19)) hangs (The _d() function seems to cause an infinite loop for large numbers. #711). To pick the default precision, the value constructor calls math::den_size, which multiplies by 10 and casts to unsigned long long until there's no fraction left. Past ~1.8e19 that cast is undefined and on GCC the remainder never hits zero, the loop just keeps going.
  • 1.e18 works because 1.e19 still fits. _f has the same issue (1.e20f).

Solution:

  • Break out once the value is too big for T. A number that big has no fractional digits anyway. Written as not(value < limit) so inf/NaN stop as well.
  • Added a few big values to the _d/_f checks in test/ut/ut.cpp.

Issue: #711

Tested on Linux with GCC 14.2 and Clang 19. With just the test change ut_test hangs (killed it after 20s). With the fix everything builds, ctest passes and the post-build run of examples/benchmarks passes. Also tried the snippet from the issue.

Reviewers:
@

@kris-jusiak
kris-jusiak merged commit f6cf5f4 into boost-ext:master Oct 20, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants