changeset 1596:df01feb2f050

* tests/fptest.c (do_test): Silence aliasing warning when breaking doubles into two ints.
author jlarmour
date Fri, 16 Apr 2004 03:33:59 +0000
parents 05e490add1fb
children 8d53540e9a4e
files packages/kernel/current/ChangeLog packages/kernel/current/tests/fptest.c
diffstat 2 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/packages/kernel/current/ChangeLog
+++ b/packages/kernel/current/ChangeLog
@@ -1,3 +1,8 @@
+2004-04-15  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* tests/fptest.c (do_test): Silence aliasing warning when breaking
+	doubles into two ints.
+
 2004-04-11  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* doc/kernel.sgml: Expanded the documentation about the use of
--- a/packages/kernel/current/tests/fptest.c
+++ b/packages/kernel/current/tests/fptest.c
@@ -173,12 +173,21 @@ static void do_test( double *values,
 
         if( sum != last_sum )
         {
+            union double_int_union {
+                double d;
+                cyg_uint32 i[2];
+            } diu_sum, diu_lastsum;
+
+            diu_sum.d = sum;
+            diu_lastsum.d = last_sum;
+            
             errors++;
+            if (sizeof(double) != 2*sizeof(cyg_uint32)) {
+                diag_printf("Warning: sizeof(double) != 2*sizeof(cyg_uint32), therefore next line may\n"
+                            "have invalid sum/last_sum values\n");
+            }
             diag_printf("%s: Sum mismatch! %d sum=[%08x:%08x] last_sum=[%08x:%08x]\n",
-                        name,j,
-                        ((cyg_uint32 *)&sum)[0],((cyg_uint32 *)&sum)[1],
-                        ((cyg_uint32 *)&last_sum)[0],((cyg_uint32 *)&last_sum)[1]
-                        );
+                        name,j, diu_sum.i[0], diu_sum.i[1], diu_lastsum.i[0], diu_lastsum.i[1] );
         }
         
 #if 0