Can compiler optimization introduce bugs?

后端 未结 22 1046
名媛妹妹
名媛妹妹 2020-11-27 13:23

Today I had a discussion with a friend of mine and we debated for a couple of hours about \"compiler optimization\".

I defended the point that sometimes

22条回答
  •  时光说笑
    2020-11-27 13:57

    I had a problem with .net 4 yesterday with something that looks like...

    double x=0.4;
    if(x<0.5) { below5(); } else { above5(); }
    

    And it would call above5(); But if I actually use x somewhere, it would call below5();

    double x=0.4;
    if(x<0.5) { below5(); } else { System.Console.Write(x); above5(); }
    

    Not the exact same code but similar.

提交回复
热议问题