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

[libc++][test] Precondition violation in rand.dist.uni.real/param_ctor.pass.cpp #100506

Open
StephanTLavavej opened this issue Jul 25, 2024 · 0 comments
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. test-suite

Comments

@StephanTLavavej
Copy link
Member

typedef std::uniform_real_distribution<float> D;
typedef D::param_type param_type;
param_type p(5);
assert(p.a() == 5);
assert(p.b() == 1);

This violates the Standard's preconditions, and MSVC's STL asserts about it. The Standardese is N4986 [rand.req.dist]/9:

For each of the constructors of D taking arguments corresponding to parameters of the distribution, P shall have a corresponding constructor subject to the same requirements and taking arguments identical in number, type, and default values.

And [rand.dist.uni.real]/2:

explicit uniform_real_distribution(RealType a, RealType b = 1.0);
Preconditions: a <= b and b - a <= numeric_limits<RealType>::max().

@github-actions github-actions bot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. test-suite
Projects
None yet
Development

No branches or pull requests

2 participants