Hi Daniel, So for my own curiosity: what went wrong here? Did compiler avoid to generate a code for while {} loop? Or something else? BTW, it is an internal function, so instead of introducing new typedef, we can just change the type of buf? Let say to uint8_t *? >From gcc manual page: " A character type may alias any other type." Would that work? Konstantin
> -----Original Message----- > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Daniel Mrzyglod > Sent: Tuesday, November 24, 2015 4:31 PM > To: dev at dpdk.org > Subject: [dpdk-dev] [PATCH v2] net: fix build with gcc 4.4.7 and strict > aliasing > > This fix is for IPv6 checksum offload error on RHEL65. > Any optimalisation above -O0 provide error in IPv6 checksum > flag "-fstrict-aliasing" is default for optimalisation above -O0. > > Fixes: 2b039d5f20a3 ("net: fix build with gcc 4.4.7 and strict aliasing") > > Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod at intel.com> > --- > lib/librte_net/rte_ip.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h > index 71c519a..5b7554a 100644 > --- a/lib/librte_net/rte_ip.h > +++ b/lib/librte_net/rte_ip.h > @@ -169,7 +169,8 @@ __rte_raw_cksum(const void *buf, size_t len, uint32_t sum) > { > /* workaround gcc strict-aliasing warning */ > uintptr_t ptr = (uintptr_t)buf; > - const uint16_t *u16 = (const uint16_t *)ptr; > + typedef uint16_t __attribute__((__may_alias__)) u16_p; > + const u16_p *u16 = (const u16_p *)ptr; > > while (len >= (sizeof(*u16) * 4)) { > sum += u16[0]; > -- > 2.5.0