skip to Main Content

Ubuntu – Undefined behavior (according to clang -fsanitize=integer) on libstdc++ std::random due to negative index on Mersenne Twister engine

I'm using clang++ 10 on Ubuntu 20.04 LTS, with -fsanitize-undefined-trap-on-error -fsanitize=address,undefined,nullability,implicit-integer-truncation,implicit-integer-arithmetic-value-change,implicit-conversion,integer My code is generating random bytes with std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<uint8_t> dd(0, 255); ... ch = uint8_t(dd(gen)); This last line causes the sanitizer to report undefined behavior is…

VIEW QUESTION
Back To Top
Search