Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: infinite hang when boost::ut::value<float>() is instantiated with large values #647

Open
proxict opened this issue Nov 24, 2024 · 0 comments

Comments

@proxict
Copy link

proxict commented Nov 24, 2024

Given this test case

expect(_t(std::numeric_limits<float>::max()) == 123.0_f);

Expected Behavior

Test case fails and prints a reasonable test failure message

Actual Behavior

Test hangs indefinitely

https://godbolt.org/z/819xv47qf

Root cause of the problem

The problem stems from the following function where value overflows in the first loop iteration and the terminating condition never evaluates to false:

https://github.com/boost-ext/ut/blob/v2.1.1/include/boost/ut.hpp#L412-L424:

template <class T, class TValue>
[[nodiscard]] constexpr auto den_size(TValue value) -> T {
  constexpr auto precision = TValue(1e-7);
  T result{};
  TValue tmp{};
  do {
    value *= 10;
    tmp = value - T(value);
    ++result;
  } while (tmp > precision);

  return result;
}

Specifications

  • Version: v.2.1.1
  • Platform: Arch Linux
  • GCC version: 14.2.1 20240910
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

No branches or pull requests

1 participant