Is something undefined behavior by omission?

后端 未结 3 532
-上瘾入骨i
-上瘾入骨i 2021-01-18 07:22

The standard says:

1.3.24                                                          [defns.undefined]
undefined behavior         


        
3条回答
  •  有刺的猬
    2021-01-18 07:38

    However, how can the standard say something is undefined behavior without explicitly saying so?

    Because that's what undefined means. What happens has not been defined. The standard defines what is expected of a valid program, it doesn't attempt to list every conceivable invalid program and say "this is undefined, also this is undefined, also this is undefined".

    The standard doesn't specify what happens if you set fire to your computer while the program is running. That doesn't mean it's well-defined. It's clearly undefined.

    Literally anything can happen in a program and it is assumed that it is not undefined behavior unless said so by the standard.

    I'm not sure what you're trying to say here, but it sounds 180° backwards.

    Does this mean a non-standard program is undefined behavior by default?

    What is a "non-standard program"?

提交回复
热议问题