From bbf36355904d04300d8316e90905ab43b470f7b1 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 8 Apr 2010 14:43:51 -0400 Subject: [PATCH] XShapeEvent strict aliasing violation C99 defines new strict aliasing rules to allow compilers to make certain optimizations. These rules prohibit converting an XEvent to an event struct (e.g. XShapeEvent) that is not already in the XEvent union using pointer type punning (e.g. "(XShapeEvent *)&ev"), and vice versa. The canonical fix seems to be to create a union between XEvent and the extension event struct to make the aliasing explicit, so do that. --- src/event.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/event.c b/src/event.c index 6f51a76e..46e2ea9a 100644 --- a/src/event.c +++ b/src/event.c @@ -1159,16 +1159,17 @@ static void handleShapeNotify(XEvent * event) { XShapeEvent *shev = (XShapeEvent *) event; WWindow *wwin; - XEvent ev; - - while (XCheckTypedWindowEvent(dpy, shev->window, event->type, &ev)) { - XShapeEvent *sev = (XShapeEvent *) & ev; - - if (sev->kind == ShapeBounding) { - if (sev->shaped == shev->shaped) { - *shev = *sev; + union { + XEvent xevent; + XShapeEvent xshape; + } ev; + + while (XCheckTypedWindowEvent(dpy, shev->window, event->type, &ev.xevent)) { + if (ev.xshape.kind == ShapeBounding) { + if (ev.xshape.shaped == shev->shaped) { + *shev = ev.xshape; } else { - XPutBackEvent(dpy, &ev); + XPutBackEvent(dpy, &ev.xevent); break; } } -- 2.11.4.GIT