C - is an indeterminate value indeterminable?

前端 未结 6 860
孤独总比滥情好
孤独总比滥情好 2020-12-03 17:45

According to this post an indeterminate value is:

3.17.2
1 indeterminate value
either an unspecified value or a trap representation

Accordi

6条回答
  •  隐瞒了意图╮
    2020-12-03 18:11

    The C90 standard made it clear that reading from an indeterminate location was undefined behavior. More recent standards are not so clear any more (indeterminate memory is “either an unspecified value or a trap representation”), but compilers still optimize in a way that is only excusable if reading an indeterminate location is undefined behavior, for instance, multiplying the integer in an uninitialized variable by two can produce an odd result.

    So, in short, no, you can't read whatever happens to occupy indeterminate memory.

提交回复
热议问题