标签:
代码片段如下:
long triptime;
long now;
triptime = (now - *((uint32_t *)(icp->icmp_data)));
上述代码在编译时由于打开了-Wall -Os选项,编译器会上报如下告警
dereferencing type-punned pointer will break strict-aliasing rules
baidu无果后,决定自己实践来,于是做如下改动:
char *ptmp = icp->icmp_data;
triptime = (now - *((uint32_t *)(ptmp)));
至此,告警消失。
编译告警处理:dereferencing type-punned pointer will break strict-aliasing rules
标签:
原文地址:http://www.cnblogs.com/sstudy-linux/p/4757110.html