int a; …; (a == a) fails?

后端 未结 9 1002
执笔经年
执笔经年 2020-12-31 19:05

if we set float and double type to NaN then they are not equal to anything including themselves.
can such a thing happens for

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-31 19:13

    It cannot happen when you compare plain initialized int variables.

    It can happen for int comparisons when you reference a hardware register, e.g. something like:

    *timeRegister == *timeRegister
    

    It could also happen when you compare a volatile int variable to itself which is modified by a signal-handler during the comparison.

提交回复
热议问题