aboutsummaryrefslogtreecommitdiffstats
path: root/code/tools
diff options
context:
space:
mode:
authorludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-11-03 17:03:54 +0000
committerludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-11-03 17:03:54 +0000
commitb31e8a67d9b1f11b9943b595a4fd66d3a07dd085 (patch)
tree712bb692c851148cf64d90d53dce9c753fb83923 /code/tools
parent5502af97628223ea8f5192647cb1dd5dbd72ae3b (diff)
downloadioquake3-aero-b31e8a67d9b1f11b9943b595a4fd66d3a07dd085.tar.gz
ioquake3-aero-b31e8a67d9b1f11b9943b595a4fd66d3a07dd085.zip
fix strict aliasing issues
Patch by Przemysław Iskra (#3805) git-svn-id: svn://svn.icculus.org/quake3/trunk@1481 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/tools')
-rw-r--r--code/tools/lcc/src/bytecode.c11
-rw-r--r--code/tools/lcc/src/c.h6
2 files changed, 12 insertions, 5 deletions
diff --git a/code/tools/lcc/src/bytecode.c b/code/tools/lcc/src/bytecode.c
index b267d6f..871056a 100644
--- a/code/tools/lcc/src/bytecode.c
+++ b/code/tools/lcc/src/bytecode.c
@@ -40,8 +40,9 @@ static void I(defconst)(int suffix, int size, Value v) {
case P: print("byte %d %U\n", size, (unsigned long)v.p); return;
case F:
if (size == 4) {
- float f = v.d;
- print("byte 4 %u\n", *(unsigned *)&f);
+ floatint_t fi;
+ fi.f = v.d;
+ print("byte 4 %u\n", fi.ui);
} else {
unsigned *p = (unsigned *)&v.d;
print("byte 4 %u\n", p[swap]);
@@ -67,10 +68,10 @@ static void I(defsymbol)(Symbol p) {
case P: p->x.name = stringf("%U", p->u.c.v.p); break;
case F:
{ // JDC: added this to get inline floats
- unsigned temp;
+ floatint_t temp;
- *(float *)&temp = p->u.c.v.d;
- p->x.name = stringf("%U", temp );
+ temp.f = p->u.c.v.d;
+ p->x.name = stringf("%U", temp.ui );
}
break;// JDC: added this
default: assert(0);
diff --git a/code/tools/lcc/src/c.h b/code/tools/lcc/src/c.h
index e36380e..68c8f62 100644
--- a/code/tools/lcc/src/c.h
+++ b/code/tools/lcc/src/c.h
@@ -98,6 +98,12 @@ typedef struct {
void *xt;
} Xtype;
+typedef union {
+ float f;
+ int i;
+ unsigned int ui;
+} floatint_t;
+
#include "config.h"
typedef struct metrics {
unsigned char size, align, outofline;