From b7145352b855e0076bfa5f6c528ef5c43a13888c Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 7 Nov 2007 00:03:09 +0000 Subject: [PATCH] Add another cast variant that might (and currently does) fail - pointed out by Holger Weiss on port-sparc64. --- regress/lib/libc/convfp/convfp.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/regress/lib/libc/convfp/convfp.c b/regress/lib/libc/convfp/convfp.c index 514ed208190d..c62ad69f77a1 100644 --- a/regress/lib/libc/convfp/convfp.c +++ b/regress/lib/libc/convfp/convfp.c @@ -1,4 +1,4 @@ -/* $NetBSD: convfp.c,v 1.5 2006/05/10 19:07:22 mrg Exp $ */ +/* $NetBSD: convfp.c,v 1.6 2007/11/07 00:03:09 martin Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -49,12 +49,14 @@ static void test1(); static void test2(); +static void test3(); int main() { test1(); test2(); + test3(); printf("PASSED\n"); return 0; } @@ -118,3 +120,25 @@ test2() printf("FAILED: %.3f casted to unsigned long is %lu\n", nv, uv); exit(1); } + +static void +test3() +{ + double dv = 1.9; + long double ldv = dv; + unsigned long l1 = dv; + unsigned long l2 = ldv; + + printf("Testing double/long double casts to unsigned long\n"); + if (l1 != 1) { + printf("FAILED: double 1.9 casted to unsigned long should" + " be 1, but is %lu\n", l1); + exit(1); + } + + if (l2 != 1) { + printf("FAILED: long double 1.9 casted to unsigned long should" + " be 1, but is %lu\n", l2); + exit(1); + } +}