首页 > 其他 > 详细

编译告警处理:dereferencing type-punned pointer will break strict-aliasing rules

时间:2015-08-25 14:02:58      阅读:1649      评论:0      收藏:0      [点我收藏+]

代码片段如下:

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!