Inconsistent behaviour in identical code

前端 未结 3 915
刺人心
刺人心 2021-01-22 11:53

An error trap trips after running a physics simulation for about 20 minutes. Realising this would be a pain to debug, I duplicated the relevant subroutine in a new project, and

3条回答
  •  天涯浪人
    2021-01-22 12:31

    *(long long int *)(&Collision_Axis_Vector.XYZ[0]) = 4594681439063077250;
    

    and all similar lines introduce Undefined Behavior in the program because they violate the Strict Aliasing rule:

    you access a double value as long long int

提交回复
热议问题