Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>EDIT 1:</strong> The last drafts of C11 and C++11 are available online here: <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf" rel="noreferrer">C11 draft N1570</a> and <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf" rel="noreferrer">C++11 draft n3242</a> if you don't have a copy of the final standards and wonderful what they look like. (Other adjustments to text appearance and some wording/grammar edits have been done.)</p> <p><strong>EDIT 2:</strong> Fixed all occurrences of "behaviour" to be "behavior" to match the standard.</p> <p>Searching the C++11 and C11 standards there are no matches for <em>indeterminate rule</em> or <em>undefined rule</em>. There are terms like <em>indeterminate value</em>, <em>indeterminately sequenced</em>, <em>indeterminate uninitialized</em>, etc.</p> <p>If talk of traps and exceptions seems weird in Norman Gray's answer, know that those terms do reflect the relevant definitions in <strong>Section 3</strong> in the <strong>C11 standard</strong>.</p> <p>C++ relies on C's definitions. Many useful definitions concerning types of <em>behaviour</em> can be found in C11's Section 3 (in C11). For example, <em>indeterminate value</em> is defined in 3.19.2. Do take note that C11's Section 2 (Normative References) provides other sources for additional terminology interpretation and Section 4 defines when cases such as <em>undefined behavior</em> occur as a result of <em>not complying</em> with the standard.</p> <p>C11's section 3.4 defines <em>behavior</em>, 3.4.1 defines <em>implementation-defined behavior</em>, 3.4.2 defines <em>locale-specific behavior</em>, 3.4.3 defines <em>undefined behavior</em>, 3.4.4 defines <em>unspecified behavior</em>. For <em>value</em> (Section 3.19), there are <em>implementation-defined value</em>, <em>indeterminate value</em>, and <em>unspecified value</em>.</p> <p>Loosely speaking, the term <strong>indeterminate</strong> refers to an <em>unspecified/unknown state</em> that by itself doesn't result in <em>undefined behavior</em>. For example, this C++ code involves an indeterminate value: { int x = x; }. (This is actually an example in the C++11 standard.) Here x is defined to be an integer first but at that point it does not have a well-defined value --then it is initialized to whatever (indeterminate/unknown) value it has!</p> <p>The well-known term <strong>undefined behavior</strong> is defined in 3.4.3 in C11 and refers to any situation of a </p> <blockquote> <p>nonportable or erroneous program construct or of erroneous data, for which this International Standard imposes no requirements</p> </blockquote> <p>In other words <em>undefined behavior</em> is some error (in logic or state) and whatever happens next is unknown! So one could make an <strong>undefined [behavior] rule</strong> that states: avoid undefined behavior when writing C/C++ code! :-)</p> <p>An <strong>indeterminate [behavior] rule</strong> would be to state: avoid writing indeterminate code <em>unless</em> it is needed <em>and</em> it does not affect program correctness or portability. So unlike undefined behavior, indeterminate behavior <em>does not necessarily</em> imply that code/data is erroneous, however, <em>its subsequent use may or may not be erroneous</em> --so care is required to ensure program correctness is maintained.</p> <p>Other terms like <em>indeterminately sequenced</em> are in the body text (e.g., C11 5.1.2.3 para 3; C++11, section 1.9 para. 13; i.e., in [intro.executation]). (As you might guess, it refers an unspecified order of operational steps.)</p> <p>IMO if one is interested in all of these nuances, acquiring both the C++11 and C11 standards is a must. This will permit one to explore to the desired level-of-detail needed with definitions, etc. If you don't have such the links provided herein will help you explore such with the last published draft C11 and C++11 standards.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload