On 2014/12/3 19:43, Richardson, Bruce wrote: > 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.
The compile version is: $ gcc -v Using built-in specs. Target: x86_64-redhat-linux ... gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) The OS is centos6.5 x86_64 Actually, another possible solution is, as gcc manual shows, use union. In function rte_raw_cksum() of lib/librte_net/rte_ip.h: static inline uint16_t rte_raw_cksum(const char *buf, size_t len){ union { const char *ubuf; const uint16_t *uu16; } convert; convert.ubuf = buf; const uint16_t *u16 = convert.uu16; ... } This may be work, but not test yet. Any comments about this solution? Thanks, Michael > > /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 >>