Are unspecified and undefined behavior required to be consistent between compiles?
Posted
by sharptooth
on Stack Overflow
See other posts from Stack Overflow
or by sharptooth
Published on 2010-06-17T08:10:01Z
Indexed on
2010/06/17
8:13 UTC
Read the original article
Hit count: 138
Let's pretend my program contains a specific construct the C++ Standard states to be unspecified behavior. This basically means the implementation has to do something reasonable but is allowed not to document it. But is the implementation required to produce the same behavior every time it compiles a specific construct with unspecified behavior or is it allowed to produce different behavior in different compiles?
What about undefined behavior? Let's pretend my program contains a construct that is UB according to the Standard. The implementation is allowed to exhibit any behavior. But can this behavior differ between compiles of the same program on the same compiler with same settings in the same environment? In other words, if I dereference a null pointer on line 78 in file X.cpp and the implementation formats the drive in such case does it mean that it will do the same after the program is recompiled?
© Stack Overflow or respective owner