Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/stdlib Test a bug found by Geza Herman.



details:   https://anonhg.NetBSD.org/src/rev/788a79248c1e
branches:  trunk
changeset: 779287:788a79248c1e
user:      alnsn <alnsn%NetBSD.org@localhost>
date:      Tue May 15 18:46:20 2012 +0000

description:
Test a bug found by Geza Herman.

diffstat:

 tests/lib/libc/stdlib/t_strtod.c |  28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diffs (56 lines):

diff -r 4feb9e5ddb1b -r 788a79248c1e tests/lib/libc/stdlib/t_strtod.c
--- a/tests/lib/libc/stdlib/t_strtod.c  Tue May 15 18:13:21 2012 +0000
+++ b/tests/lib/libc/stdlib/t_strtod.c  Tue May 15 18:46:20 2012 +0000
@@ -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@localhost>, 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_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_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();
 }



Home | Main Index | Thread Index | Old Index