The standard says:
1.3.24 [defns.undefined]
undefined behavior
behavior for which this International Standard imposes no requirements
[Note: Undefined behavior may be expected when this International Standard
omits any explicit definition of behavior or when a program uses an erroneous
construct or erroneous data. Permissible undefined behavior ranges from ignoring
the situation completely with unpredictable results, to behaving during
translation or program execution in a documented manner characteristic of the
environment (with or without the issuance of a diagnostic message), to
terminating a translation or execution (with the issuance of a diagnostic
message). Many erroneous program constructs do not engender undefined behavior;
they are required to be diagnosed.
- end note]
Obviously, the standard cannot cover all possible aspects of behavior. Therefore, it seems that if something is not covered by the standard, it may be undefined. What exactly does this mean?
He implied that if a standard does not cover anything, it cannot impose requirements on it. However, how can a standard say something like undefined behavior without saying it explicitly? Literally, something can happen in the program, and it is assumed that this is not undefined behavior unless specified by the standard. Does this mean that by default a non-standard program has undefined behavior?
The respondent says the notes are non-normative. Answers to this Are notes and examples in the specification of the main language of the standard non-standard standard C ++? which says:
The notes and examples included in the text of the document should be used to provide additional information designed to help understand or use the document. They should not contain requirements (“must”, see 3.3.1 and table H.1) or any information is considered indispensable for using the document, for example. instructions (required, see table H.1), recommendations (“should”; see 3.3.2 and table H.2) or authorization (“may”, see table H.3). Notes can be written as a statement of fact.
It seems to me that something that is omitted is not strictly undefined behavior. For example, is this something strict undefined behavior if it is mentioned in a note?
source share