jcf-dump.c (print_constant, [...]): Don't fall foul of type-based aliasing.
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 1 Oct 2002 19:13:12 +0000 (19:13 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 1 Oct 2002 19:13:12 +0000 (19:13 +0000)
* jcf-dump.c (print_constant, case CONSTANT_float): Don't fall
foul of type-based aliasing.

From-SVN: r57699

gcc/java/ChangeLog
gcc/java/jcf-dump.c

index 9b2ad12..07c53ec 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-01  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * jcf-dump.c (print_constant, case CONSTANT_float): Don't fall
+       foul of type-based aliasing.
+
 2002-09-30  Anthony Green  <green@redhat.com>
 
        * gcj.texi (Invoking jv-scan): Fix texinfo.
index 13a177d..2824a6b 100644 (file)
@@ -504,10 +504,18 @@ DEFUN(print_constant, (out, jcf, index, verbosity),
       break;
     case CONSTANT_Float:
       {
-       jfloat fnum = JPOOL_FLOAT (jcf, index);
-       fprintf (out, "%s%.10g", verbosity > 0 ? "Float " : "", (double) fnum);
+       union
+       {
+         jfloat f;
+         int32 i;
+       } pun;
+       
+       pun.f = JPOOL_FLOAT (jcf, index);
+       fprintf (out, "%s%.10g",
+                verbosity > 0 ? "Float " : "", (double) pun.f);
        if (verbosity > 1)
-         fprintf (out, ", bits = 0x%08lx", (long) (* (int32 *) &fnum));
+         fprintf (out, ", bits = 0x%08lx", (long) pun.i);
+       
        break;
       }
     case CONSTANT_Double: