File squirrel-aliasing.patch of Package squirrel

Index: squirrel/sqvm.cpp
===================================================================
--- squirrel/sqvm.cpp.orig	2011-11-10 18:42:18.999089829 +0100
+++ squirrel/sqvm.cpp	2011-11-10 18:44:06.208573541 +0100
@@ -695,7 +695,11 @@ exception_restore:
 #else
 				TARGET = (SQInteger)((SQUnsignedInteger32)arg1); continue;
 #endif
-			case _OP_LOADFLOAT: TARGET = *((SQFloat *)&arg1); continue;
+			case _OP_LOADFLOAT: {
+				union{ const SQInt32 *sqi32p; const SQFloat *sqfp; }pun = { &arg1 };
+				TARGET = *pun.sqfp;
+				}
+				continue;
 			case _OP_DLOAD: TARGET = ci->_literals[arg1]; STK(arg2) = ci->_literals[arg3];continue;
 			case _OP_TAILCALL:{
 				SQObjectPtr &t = STK(arg1);
@@ -881,10 +885,12 @@ exception_restore:
 					val._unVal.nInteger = (SQInteger)((SQUnsignedInteger32)arg1);
 #endif
 					break;
-				case AAT_FLOAT:
-					val._type = OT_FLOAT;
-					val._unVal.fFloat = *((SQFloat *)&arg1);
-					break;
+				case AAT_FLOAT: {
+						union{ const SQInt32 *sqi32p; const SQFloat *sqfp; }pun = { &arg1 };
+						val._type = OT_FLOAT;
+						val._unVal.fFloat = *pun.sqfp;
+ 					break;
+					}
 				case AAT_BOOL:
 					val._type = OT_BOOL;
 					val._unVal.nInteger = arg1;
Index: squirrel/sqcompiler.cpp
===================================================================
--- squirrel/sqcompiler.cpp.orig	2011-11-10 18:42:18.999089829 +0100
+++ squirrel/sqcompiler.cpp	2011-11-10 18:44:06.214573456 +0100
@@ -869,7 +869,9 @@ public:
 			target = _fs->PushTarget();
 		}
 		if(sizeof(SQFloat) == sizeof(SQInt32)) {
-			_fs->AddInstruction(_OP_LOADFLOAT, target,*((SQInt32 *)&value));
+            union{SQFloat *sqfp; SQInt32 *sqi32p; }pun = { &value };
+
+            _fs->AddInstruction(_OP_LOADFLOAT, target, *pun.sqi32p);
 		}
 		else {
 			_fs->AddInstruction(_OP_LOAD, target, _fs->GetNumericConstant(value));
Index: sqstdlib/sqstdblob.cpp
===================================================================
--- sqstdlib/sqstdblob.cpp.orig	2011-11-10 18:42:19.000089815 +0100
+++ sqstdlib/sqstdblob.cpp	2011-11-10 18:44:06.227573272 +0100
@@ -174,16 +174,18 @@ static SQRegFunction _blob_methods[] = {
 static SQInteger _g_blob_casti2f(HSQUIRRELVM v)
 {
 	SQInteger i;
+	union{ SQInteger *sqip; SQFloat *sqfp;}pun = { &i };
 	sq_getinteger(v,2,&i);
-	sq_pushfloat(v,*((SQFloat *)&i));
+	sq_pushfloat(v,*pun.sqfp);
 	return 1;
 }
 
 static SQInteger _g_blob_castf2i(HSQUIRRELVM v)
 {
 	SQFloat f;
+	union{ SQFloat *sqfp; SQInteger *sqip;}pun = { &f };
 	sq_getfloat(v,2,&f);
-	sq_pushinteger(v,*((SQInteger *)&f));
+	sq_pushinteger(v,*pun.sqip);
 	return 1;
 }
 
openSUSE Build Service is sponsored by