| Issue |
75782
|
| Summary |
[libcxx] std::normal_distribution may need a static assertion
|
| Labels |
libc++
|
| Assignees |
|
| Reporter |
GuF-veg
|
Consider this code:

Using clang + llvm + libc++ toolchain (version: 17.0.6), this code will compile successfully.
But it will lead to runtime errors:


Refer to cppreference, the template parameter of std::normal_distribution must be a float point type. In another word, it must be float, double or long double, otherwise it will lead to a **Undefined Behaviour**.
I compile this code with GCC-13.2.0, it will arise a compilation error:

The reason is that there is a **static_assert** in GCC STL library random.h:

But there isn't a static_assert in LLVM Libc++ library normal_distribution.h:

So I think it may be a good idea to add a static assertion in LLVM library, in this way we can avoid a lot of latent errors.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs