From: ellson Date: Wed, 24 May 2006 14:44:12 +0000 (+0000) Subject: fix a "dereferencing type-punned pointer will break strict-aliasing rules" warning X-Git-Tag: LAST_LIBGRAPH~32^2~6559 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58e0c19b20c6056d6731a8c391d8ebd765e64ced;p=graphviz fix a "dereferencing type-punned pointer will break strict-aliasing rules" warning --- diff --git a/lib/gd/fontwheeltest.c b/lib/gd/fontwheeltest.c index b552b6a9c..b8e4f59ae 100644 --- a/lib/gd/fontwheeltest.c +++ b/lib/gd/fontwheeltest.c @@ -22,6 +22,8 @@ dowheel (gdImagePtr im, int color, char *fontfile, int fontsize, double angle, int x, int y, int offset, char *string) { int brect[8]; + gdPoint points[4]; + int i; FILE *err; double curangrads, curang, x0, y0; char *cp; @@ -49,7 +51,15 @@ dowheel (gdImagePtr im, int color, char *fontfile, int fontsize, if (cp) doerr (err, cp); - gdImagePolygon (im, (gdPointPtr)brect, 4, color); + /* FIXME - this is silly, but if we try to cast int[] to gdPointPtr + * we get a "warning: dereferencing type-punned pointer will break strict -aliasing rules" from gcc + * The proper fix probably requires an API change to use gdPoint[] in gdImageString* + */ + for (i = 0; i < 4; i++) { + points[i].x = brect[2*i]; + points[i].y = brect[2*i + 1]; + } + gdImagePolygon (im, points, 4, color); } fclose (err);