Module Name: src
Committed By: alnsn
Date: Tue May 15 18:46:20 UTC 2012
Modified Files:
src/tests/lib/libc/stdlib: t_strtod.c
Log Message:
Test a bug found by Geza Herman.
To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/tests/lib/libc/stdlib/t_strtod.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/libc/stdlib/t_strtod.c
diff -u src/tests/lib/libc/stdlib/t_strtod.c:1.29 src/tests/lib/libc/stdlib/t_strtod.c:1.30
--- src/tests/lib/libc/stdlib/t_strtod.c:1.29 Wed Apr 4 10:52:59 2012
+++ src/tests/lib/libc/stdlib/t_strtod.c Tue May 15 18:46:20 2012
@@ -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 <[email protected]>, 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();
}