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 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/event.c b/src/event.c
index 6f51a76..46e2ea9 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;
                        }
                }
-- 
1.7.0.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to