查看: 4461|回复: 0

遇到个别编译器优化导致逻辑判断异常

[复制链接]
  • TA的每日心情

    2025-8-20 09:12
  • 签到天数: 84 天

    连续签到: 1 天

    [LV.6]常住居民II

    7

    主题

    3453

    帖子

    0

    金牌会员

    Rank: 6Rank: 6

    积分
    3082
    最后登录
    2025-9-9
    发表于 2021-5-31 13:54:07 | 显示全部楼层 |阅读模式
    这个while判断,在有的编译器中,优化,导致数组异常,排查了很久。
    while((j < 4)&&((eeprom.Info.Vendor[j] <= 0x7A) && (eeprom.Info.Vendor[j] >= 0x30)))
        {
                    MaTemp[i++] = eeprom.Info.Vendor[j++];
        }
    后来工程统一更改判断规则,避免编译器的优化。如下写法。
    while(j < 4)
        {
            if((eeprom.Info.Vendor[j] <= 0x7A) && (eeprom.Info.Vendor[j] >= 0x30))
                MaTemp[i++] = eeprom.Info.Vendor[j++];
            else
                break;
        }

    该会员没有填写今日想说内容.
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-9-11 23:25 , Processed in 0.076735 second(s), 19 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表