Skip to content

Commit 1fbdc50

Browse files
committed
add more asserts to polynomial
1 parent e7ae80c commit 1fbdc50

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

source/mir/polynomial.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ struct Polynomial(F)
4646
if (coefficients)
4747
{
4848
ptrdiff_t i = coefficients.length - 1;
49+
assert(i >= 0);
4950
auto c = cast()coefficients[i];
5051
static foreach (d; Iota!derivative)
5152
c *= i - d;
5253
ret = cast(typeof(return)) c;
53-
while (--i >= derivative)
54+
while (--i >= cast(ptrdiff_t)derivative)
5455
{
56+
assert(i < coefficients.length);
5557
c = cast()coefficients[i];
5658
static foreach (d; Iota!derivative)
5759
c *= i - d;

0 commit comments

Comments
 (0)