Can code that will never be executed invoke undefined behavior?

后端 未结 9 1618
予麋鹿
予麋鹿 2020-11-27 17:52

The code that invokes undefined behavior (in this example, division by zero) will never get executed, is the program still undefined behavior?

int main(void)         


        
9条回答
  •  余生分开走
    2020-11-27 18:07

    Only when the standard makes breaking changes and your code suddenly is no longer "never gets executed". But I don't see any logical way in which this can cause 'undefined behaviour'. Its not causing anything.

提交回复
热议问题