diff options
| author | alnsn <alnsn@NetBSD.org> | 2012-05-15 18:46:20 +0000 |
|---|---|---|
| committer | alnsn <alnsn@NetBSD.org> | 2012-05-15 18:46:20 +0000 |
| commit | 80efc48df413c11244dd72256e31a3e6e0ed14ca (patch) | |
| tree | bbfd66827357ad91642eb4fea8cbe01fb528916f /tests/lib/libc/stdlib | |
| parent | 181506f0a9d95baadd48717719ac3dc754f989cf (diff) | |
Test a bug found by Geza Herman.
Diffstat (limited to 'tests/lib/libc/stdlib')
| -rw-r--r-- | tests/lib/libc/stdlib/t_strtod.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/lib/libc/stdlib/t_strtod.c b/tests/lib/libc/stdlib/t_strtod.c index 127e27a4cb8..b4cad56eba8 100644 --- a/tests/lib/libc/stdlib/t_strtod.c +++ b/tests/lib/libc/stdlib/t_strtod.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_strtod.c,v 1.29 2012/04/04 10:52:59 joerg Exp $ */ +/* $NetBSD: t_strtod.c,v 1.30 2012/05/15 18:46:20 alnsn Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ /* Public domain, Otto Moerbeek <otto@drijf.net>, 2006. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_strtod.c,v 1.29 2012/04/04 10:52:59 joerg Exp $"); +__RCSID("$NetBSD: t_strtod.c,v 1.30 2012/05/15 18:46:20 alnsn Exp $"); #include <errno.h> #include <math.h> @@ -298,6 +298,29 @@ ATF_TC_BODY(strtod_underflow, tc) atf_tc_fail("strtod(3) did not detect underflow"); } +/* + * Bug found by Geza Herman. + * See + * http://www.exploringbinary.com/a-bug-in-the-bigcomp-function-of-david-gays-strtod/ + */ +ATF_TC(strtod_gherman_bug); +ATF_TC_HEAD(strtod_gherman_bug, tc) +{ + atf_tc_set_md_var(tc, "descr", "Test a bug found by Geza Herman"); +} + +ATF_TC_BODY(strtod_gherman_bug, tc) +{ + + const char *str = + "1.8254370818746402660437411213933955878019332885742187"; + + errno = 0; + volatile double d = strtod(str, NULL); + + ATF_CHECK(d == 0x1.d34fd8378ea83p+0); +} + ATF_TP_ADD_TCS(tp) { @@ -311,6 +334,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, strtold_nan); ATF_TP_ADD_TC(tp, strtod_round); ATF_TP_ADD_TC(tp, strtod_underflow); + ATF_TP_ADD_TC(tp, strtod_gherman_bug); return atf_no_error(); } |
