[dpdk-dev] [PATCH] test-pmd: Fix pointer aliasing error

Bruce Richardson bruce.richardson at intel.com
Wed Dec 3 12:42:58 CET 2014


On Wed, Dec 03, 2014 at 07:28:19PM +0800, Michael Qiu wrote:
> app/test-pmd/csumonly.c: In function ‘get_psd_sum’:
> build/include/rte_ip.h:161: error: dereferencing pointer ‘u16’
> 	does break strict-aliasing rules
> build/include/rte_ip.h:157: note: initialized from here
> 	...
> 
> The root cause is that, compile enable strict aliasing by default,
> while in function rte_raw_cksum() try to convert 'const char *'
> to 'const uint16_t *'.
>

What compiler version is this with? Is there any other way to fix this
other than disabling the compiler warnings. Turning off strict aliasing may
affect performance as it reduces the number of optimizations that the compiler
can perform.

/Bruce

> Need to add CFLAG '-Wno-strict-aliasing' to avoid this issue.
> 
> Signed-off-by: Michael Qiu <michael.qiu at intel.com>
> ---
>  app/test-pmd/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
> index 97dc2e6..995c874 100644
> --- a/app/test-pmd/Makefile
> +++ b/app/test-pmd/Makefile
> @@ -38,7 +38,7 @@ ifeq ($(CONFIG_RTE_TEST_PMD),y)
>  #
>  APP = testpmd
>  
> -CFLAGS += -O3
> +CFLAGS += -O3 -Wno-strict-aliasing
>  CFLAGS += $(WERROR_FLAGS)
>  
>  ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
> -- 
> 1.9.3
> 


More information about the dev mailing list