[systemd-devel] [PATCH] configure: add -Wno-cast-align to CFLAGS

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Mon Jul 15 20:58:08 PDT 2013


On Mon, Jul 15, 2013 at 07:55:57PM -0700, Shawn wrote:
> On Mon, Jul 15, 2013 at 7:26 PM, Lennart Poettering
> <lennart at poettering.net>wrote:
> 
> > On Mon, 15.07.13 18:22, Shawn Landden (shawnlandden at gmail.com) wrote:
> >
> > > these warnings on !x86 arches for good code are annoying, and
> > > there is no way to mark the offending code safe, so I guess we are
> > > just going to have to deal with the resulting problems as we
> > > come across them. Also, these warnings are present for armv6+armv7,
> > > when they moreso effect armv5.
> >
> > Hmm, can you elaborate on the particular places where this happens? I
> > have not been aware of any issues regarding this (not surprising since I
> > am a boring x86 user...)
> >
> Here is the full build log on armhf. I looked at the source for some of
> these about a year ago, after the udev merge. Basically, you allocate
> some type to 1-byte aligned, and then you cast it to a type that requries
> 4-bytes aligned, and on arches that do
> not support unaligned accesses, Bad Things (tm) happen. I ran systemd on
> armv5 for quite some time and never had problems, however, but fewer people
> are probably testing that now. (I don't have the hardware anymore)
malloc(3) says "functions return a pointer to the allocated memory
that is suitably aligned for any kind of variable", which means that
the beginning of the struct is maximally aligned, and then individual fields
are also aligned, so everything is OK. But when the pointer to the
field is cast to (char*) and back, the compiler thinks that the alignment
is random.

One gets the same stupid output with clang on amd64.

Zbyszek


More information about the systemd-devel mailing list