I have problem with following code:
#include <cassert>
#include <limits>
#include <random>
int main() {
using T = long double;
std::mt19937 engine{ std::random_device{}() };
const auto max = std::numeric_limits<T>::max();
const auto res = std::uniform_real_distribution<T>(0., max)(engine);
assert(res < max);
}
This code executes properly as a standalone program. Unfortunately, under Valgrind the assertion is unsatisfied. The problem occurs only for T == long double, i.e. double and float cases are not problematic.
Can you explain the nature of the problem?
(I work with GCC 9.3.0 and Valgrind 3.15.0 on GNU/Linux x86_64. I used -O0 -g flags for GCC and --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all --run-cxx-freeres=yes for Valgrind.)