F
Frederick Gotham
I have a general idea of the different kinds of behaviour described by the
C Standard, such as:
(1) Well-defined behaviour:
int a = 2, b = 3;
int c = a + b;
(Jist: The code will work perfectly.)
(2) Implementation-defined behaviour
unsigned i = -1;
if (i > 65535) DoSomething();
else DoSomethingElse();
(Jist: Different things can happen on different platforms, but the
program shouldn't crash.)
(3) Unspecified Behaviour
int i = Func1() + Func2();
(Jist: We don't know which function is called first.)
(4) Undefined Behaviour
int i = INT_MAX;
++i;
(The implementation can do whatever it likes, and the program may very
well crash.)
I'm looking for a term though to describe a code snippet which _might_
invoke undefined behaviour. Here's an example:
int i = 32767;
++i;
Given the minimum range of "int", this code may fail on some systems and
succeed on others. I hestitate though to simply label it as "undefined
behaviour". How would I describe a code snippet which may invoke undefined
behaviour depending on implementation-specific details?
C Standard, such as:
(1) Well-defined behaviour:
int a = 2, b = 3;
int c = a + b;
(Jist: The code will work perfectly.)
(2) Implementation-defined behaviour
unsigned i = -1;
if (i > 65535) DoSomething();
else DoSomethingElse();
(Jist: Different things can happen on different platforms, but the
program shouldn't crash.)
(3) Unspecified Behaviour
int i = Func1() + Func2();
(Jist: We don't know which function is called first.)
(4) Undefined Behaviour
int i = INT_MAX;
++i;
(The implementation can do whatever it likes, and the program may very
well crash.)
I'm looking for a term though to describe a code snippet which _might_
invoke undefined behaviour. Here's an example:
int i = 32767;
++i;
Given the minimum range of "int", this code may fail on some systems and
succeed on others. I hestitate though to simply label it as "undefined
behaviour". How would I describe a code snippet which may invoke undefined
behaviour depending on implementation-specific details?