Optimizing away a “while(1);” in C++0x

前端 未结 8 1365
生来不讨喜
生来不讨喜 2020-11-22 10:37

Updated, see below!

I have heard and read that C++0x allows an compiler to print \"Hello\" for the following snippet

#include 

        
8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 10:55

    I think it's worth pointing out that loops which would be infinite except for the fact that they interact with other threads via non-volatile, non-synchronised variables can now yield incorrect behaviour with a new compiler.

    I other words, make your globals volatile -- as well as arguments passed into such a loop via pointer/reference.

提交回复
热议问题