[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] [patch] GemLib grect_to_array()



Hello.

Here is a patch for the function grect_to_array() in the GemLib.
The previous implementation was wrong with GCC 4.x due to the "strict aliasing" feature turned on by default. The fix is obvious.

This bug has been detected by Olivier Landemarre.

I don't know if this function is used by XaAES, but it may be an explanation for a lot of trouble with GEM programs compiled with GCC 4.x.

Please commit.

--
Vincent Rivière
diff -aurN -x CVS lib.orig/gemlib/rc_grect_to_array.c lib/gemlib/rc_grect_to_array.c
--- lib.orig/gemlib/rc_grect_to_array.c	2003-02-28 21:46:41.000000000 +0100
+++ lib/gemlib/rc_grect_to_array.c	2010-02-16 21:46:29.109375000 +0100
@@ -18,11 +18,10 @@
 short *
 grect_to_array (const GRECT * area, short *array)
 {
-	long *p = (long*)array;
-	
-	p[0] = p[1] = *(const long*)area;
-	array[2] += area->g_w -1;
-	array[3] += area->g_h -1;
+	array[0] = area->g_x;
+	array[1] = area->g_y;
+	array[2] = area->g_x + area->g_w - 1;
+	array[3] = area->g_y + area->g_h - 1;
 	
 	return array;
 }