Issue 182397
Summary [libc++][test] rand.dist.bern.negbin/eval.pass.cpp constructs with `p == 1`, which has undefined behavior
Labels libc++
Assignees
Reporter StephanTLavavej
    This test constructs a `negative_binomial_distribution` from `(40, 1)`:

https://github.com/llvm/llvm-project/blob/f6c86bd69d92e82096fa98f8e38bb7ebf4ce9274/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp#L167-L170

But [N5032](https://isocpp.org/files/papers/N5032.pdf) \[rand.dist.bern.negbin\]/1 notes that this has undefined behavior: "\[*Note 1:* This implies that *P(i | k, p)* is undefined when `p == 1`. *- end note*\]"

This test should be fixed to pass an argument for `p` that's strictly less than `1.0`.

(There's a wording defect here that I was unable to get LWG to fix. /2's Preconditions specify "0 < `p` <= 1", but it makes absolutely no sense for the Preconditions to allow `p == 1` when any use of the resulting distribution will be doomed to have undefined behavior. The arguments against changing this were uncompelling but it wasn't worth my time to push further. In any event, the fact that the Preconditions allow this, doesn't make the resulting distribution usage any more valid.)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to