<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.32.2">
</HEAD>
<BODY>
On Mon, 2011-12-05 at 13:51 +1000, Peter Hutterer wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
On Sun, Dec 04, 2011 at 09:16:41PM -0500, Gaetan Nadon wrote:
> On Mon, 2011-12-05 at 10:37 +1000, Peter Hutterer wrote:
>
> > Compiler warning:
> > xinput.c:272: warning: dereferencing pointer 'e' does break strict-aliasing
> > rules
> >
> > The code itself is the usual XInput client-side code:
> > XEvent event;
> > XDeviceMotionEvent *e = (XDeviceMotionEvent *)&event;
> > XNextEvent(display, &event);
> > printf("%d\n", e->type);
> >
> > Since XDeviceMotionEvent is not guaranteed the same size as XEvent, clients
> > must use pointer aliasing as above when using the XNextEvent API. Disable
> > strict aliasing for this example.
> >
> > Signed-off-by: Peter Hutterer <<A HREF="mailto:peter.hutterer@who-t.net">peter.hutterer@who-t.net</A>>
> > ---
> > If I understand this correctly, this is endemic to virtually any XI
> > application. Point could be made to disable strict aliasing for the whole
> > examples directory here instead of just the xinput example here but none of
> > the others complain as of yet.
> >
> > configure.ac | 1 +
> > 1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index d2aaeb1..3443583 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -1968,6 +1968,7 @@ dnl Linux sources in DMX require <linux/keyboard.h>
> >         AC_SUBST(DMXXMUEXAMPLES_DEP_LIBS)
> >         PKG_CHECK_MODULES([DMXXIEXAMPLES_DEP], [$LIBDMX $LIBXI $LIBXEXT x11])
> >         AC_SUBST(DMXXIEXAMPLES_DEP_LIBS)
> > +        DMXXIEXAMPLES_DEP_CFLAGS+="-fno-strict-aliasing"
>
> Shouldn't this be similar to line 93 above?
>
> if test "x$GCC" = xyes ; then
> XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing"
> fi
>
> One cannot presume that only gcc will ever compile this code, unless I
> missed some equivalent test somewhere.
right, of course. I'll fix that up.
> I don't get any warning in my build output and I don't see any -W option
> (patch not applied):
>
> gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../../../include
> -I/home/nadon/xorg/src/inst/include -g -O2 -MT xinput-xinput.o -MD -MP
> -MF .deps/xinput-xinput.Tpo -c -o xinput-xinput.o `test -f 'xinput.c' ||
> echo './'`xinput.c
tbh, I'm not 100% what other conditions need to be true here. I can't
reproduce it on my machine but on our build-systems it produces the above
warning without this fix.
</PRE>
</BLOCKQUOTE>
Most likely they add warning compiler options on the build machine. Consider adding $(CWARNFLAGS) in the makefile. I was somewhat surprised to see it was missing. <BR>
You may want to wait until util-macros v 1.16 where Jeremy reorged the warning flags and separated them from fno-strict-aliasing which will fit nicely with this patch.
<BLOCKQUOTE TYPE=CITE>
<PRE>
Cheers,
Peter
> >         PKG_CHECK_MODULES([XTSTEXAMPLES_DEP], [$LIBXTST $LIBXEXT x11])
> >         AC_SUBST(XTSTEXAMPLES_DEP_LIBS)
> >         PKG_CHECK_MODULES([XRESEXAMPLES_DEP], [xres $LIBXEXT x11])
>
>
</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>