On
01/12/14 14:37, John Haxby wrote:
With gcc 4.8.3, compiling xen-detect gives a
compilation warning if
you're optimising:
$ cc -Wall -Os xen-detect.c
xen-detect.c: In function ‘check_for_xen’:
xen-detect.c:65:9: warning: dereferencing type-punned
pointer will break
strict-aliasing rules [-Wstrict-aliasing]
*(uint32_t *)(signature + 0) = regs[1];
^
Signed-off-by: John Haxby <john.haxby@oracle.com>
Why are you
compiling without the CFLAGS from the Xen build system?
We explicitly
disable strict alias optimisations, because optimisations
based upon the
aliasing rules in C is mad. Even when you eliminate all
the warnings,
there are still subtle bugs because the compiler is free
to assume a
lot more than a programmer would typically deem
reasonable.
I wasn’t building the whole system, I just wanted
xen-detect so I pulled it out and compiled it; I usually use
"-Wall -Os” because the combination finds problems I might
otherwise overlook. The patch also removes three lines of code
:) but you can take it or leave it as you choose. The other
patch — reversing the code of pv and hvm checking — was the real
problem.
jch