changeset 15959:dcb042d5500d

Fix for gcc 4 and strict-aliasing. Patch by Uoti A Urpala ( urpala () cc ! helsinki ! fi ).
author mosu
date Sun, 10 Jul 2005 18:31:13 +0000
parents 087142ef3a2d
children 4007949d98bc
files libmpdemux/ebml.c
diffstat 1 files changed, 9 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/ebml.c	Sun Jul 10 17:14:12 2005 +0000
+++ b/libmpdemux/ebml.c	Sun Jul 10 18:31:13 2005 +0000
@@ -175,30 +175,26 @@
     {
     case 4:
       {
-        uint32_t i;
-        float *f;
-        i = stream_read_dword (s);
-        f = (float *) (void *) &i;
-        value = *f;
+        union {uint32_t i; float f;} u;
+        u.i = stream_read_dword (s);
+        value = u.f;
         break;
       }
 
     case 8:
       {
-        uint64_t i;
-        double *d;
-        i = stream_read_qword (s);
-        d = (double *) (void *) &i;
-        value = *d;
+        union {uint64_t i; double d;} u;
+        u.i = stream_read_qword (s);
+        value = u.d;
         break;
       }
 
     case 10:
       {
-        uint8_t data[10];
-        if (stream_read (s, data, 10) != 10)
+        union {uint8_t data[10]; long double ld;} u;
+        if (stream_read (s, u.data, 10) != 10)
           return EBML_FLOAT_INVALID;
-        value = * (long double *) data;
+        value = u.ld;
         break;
       }