Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 4420289

Browse files
committed
Add FMA tests that cause it to segfault
1 parent 3a59e93 commit 4420289

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/math/fma.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,22 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
205205
}
206206
scalbn(r, e)
207207
}
208+
209+
#[cfg(test)]
210+
mod tests {
211+
use super::*;
212+
#[test]
213+
fn fma_segfault() {
214+
// These two inputs cause fma to segfault on release due to overflow:
215+
assert_eq!(
216+
fma(
217+
-0.0000000000000002220446049250313,
218+
-0.0000000000000002220446049250313,
219+
-0.0000000000000002220446049250313
220+
),
221+
-0.00000000000000022204460492503126,
222+
);
223+
224+
assert_eq!(fma(-0.992, -0.992, -0.992), -0.00793599999988632,);
225+
}
226+
}

tests/unit.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use libm::*;
2+
3+
#[test]
4+
fn fma_segfault() {
5+
// These two inputs cause fma to segfault on release due to overflow:
6+
assert_eq!(
7+
fma(
8+
-0.0000000000000002220446049250313,
9+
-0.0000000000000002220446049250313,
10+
-0.0000000000000002220446049250313
11+
),
12+
-0.00000000000000022204460492503126,
13+
);
14+
15+
assert_eq!(
16+
fma(-0.992, -0.992, -0.992),
17+
-0.00793599999988632,
18+
);
19+
}

0 commit comments

Comments
 (0)