Understanding the warning “comparison of promoted ~unsigned with unsigned”

后端 未结 2 1771
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 02:43

I\'ve encountered a warning that I don\'t really understand. The warning is generated by comparing what I consider to be one unsigned with another unsigned.

Here is

相关标签:
2条回答
  • 2021-01-18 03:11

    I had the same problem and I worked around it by using an intermediate variable:

    uint8_t check = ~arr[2];
    if (arr[3] != check)
    
    0 讨论(0)
  • 2021-01-18 03:26

    Yes I think its a bug. Read [Bug c/38341] Wrong warning comparison of promoted ~unsigned with unsigned and also Why, warning: comparison between signed and unsigned integer expressions?. This might help you.

    0 讨论(0)
提交回复
热议问题