[SLOF] [PATCH] libnet: Fix compiler warnings with GCC 9
segher at kernel.crashing.org
Mon Sep 23 20:49:01 AEST 2019
On Mon, Sep 23, 2019 at 08:16:21AM +0200, Thomas Huth wrote:
> > Or disable this particular warning. What exactly
> > does it protect against?
> If I've googled it right, assigning an unaligned pointer value is
> undefined behavior according to the C standard. So the compiler could do
> weird stuff if we simply ignore it.
It is UB indeed, see C11 126.96.36.199/7:
A pointer to an object type may be converted to a pointer to a
different object type. If the resulting pointer is not correctly
aligned for the referenced type, the behavior is undefined.
I like to point people to
for how to avoid causing such silly problems in the first place.
More information about the SLOF