-
Notifications
You must be signed in to change notification settings - Fork 75
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
Divide by zero in munit_rand_state_at_most() #30
Comments
I haven't tried it, but |
Ah yep, that could be the case. I've been randomising min/max and they meet
at 0 so there's a chance I called it with (0, 0)
…On Fri, 24 Mar 2017 at 5:52 pm, Jørgen Ibsen ***@***.***> wrote:
I haven't tried it, but munit_rand_int_range() passes the range (max - min)
as the max parameter (line 714). So max in line 676 should only be 0 if
min and max are equal?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#30 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAWRZzvj25JZn4kKISqb9r_BY00nkdblks5ro3YlgaJpZM4MnxC2>
.
|
Interesting. It's somewhat nonsensical to call My first thought is to add a I'm leaning toward the assertion, but first: does anyone have an opinion? |
Since the range is inclusive, I would be inclined to say that asking for a random number in [1, 1] should return 1. |
Fixed by returning |
This issue seems to persist in the master branch. Today, I used |
.. when calling
munit_rand_int_range(any_negative_int, 0);
Address sanitizer:
Valgrind:
The
% max
whenmax=0
is the issue on line 676:The text was updated successfully, but these errors were encountered: