Are notes and examples in the core language specification of the C++ Standard non-normative?
Asked Answered
H

3

27

Often on SO (and elsewhere) I have seen the claim that notes and examples in the C++ Standard are not normative - I have probably made this claim myself a few times.

However, I could not find evidence of this fact in the core language specification of the C++ Standard (at the moment I am looking at the n3979 Working Draft for C++14).

The closest quote I could find is in paragraph 17.5.1.2/2:

Paragraphs labeled “Note(s):” or “Example(s):” are informative, other paragraphs are normative.

However, unless I'm mistaken that paragraph only applies to the Library part (i.e. Clauses 18 through 30 and Annex D).

Hence the question: Are all notes and examples in the C++ Standard non-normative? How about footnotes?

Heterozygous answered 26/1, 2014 at 14:12 Comment(0)
K
32

See §6.5 of the ISO/IEC Directives Part 2. Notes, examples, and footnotes are all considered "informational", as opposed to "normative".

For notes and examples:

Notes and examples integrated in the text of a document shall only be used for giving additional information intended to assist the understanding or use of the document. They shall not contain requirements ("shall"; see 3.3.1 and Table H.1) or any information considered indispensable for the use of the document, e.g. instructions (imperative; see Table H.1), recommendations ("should"; see 3.3.2 and Table H.2) or permission ("may"; see Table H.3). Notes may be written as a statement of fact.

For footnotes:

Footnotes to the text give additional information; their use shall be kept to a minimum. As is the case for notes and examples integrated in the text (see 6.5.1) footnotes shall not contain requirements or any information considered indispensable for the use of the document.

However, note that footnotes to figures and tables can contain requirements.

Kingly answered 26/1, 2014 at 14:17 Comment(2)
+1 for citing the normative -rather than the informational one I cited- document. @AndyProwl, accept this one please.Umlaut
The link given here is dead; there's a newer version of this document available at here. Its structure is completely different (so the sections quoted above are no longer present verbatim), but it says basically the same things.Oriel
U
12

This is generic for all ISO standard documents:

An example integrated in the text of a document, used for giving additional information intended to assist the understanding or use of the document. In ISO standards, examples are without exception non-normative.

A similar clause applies to notes:

A note integrated in the text of a document, used for giving additional information intended to assist the understanding or use of the document. In ISO standards, notes are without exception non-normative.

Umlaut answered 26/1, 2014 at 14:13 Comment(8)
Most ISO documents seek to describe categories of "conforming" objects in sufficient detail to guarantee something about the effects of combining them, making distinctions between normative and non-normative sections very important. The C Standard, however, would allow a contrived implementation to be conforming and yet be incapable of running anything other than a contrived and useless program, and would allow a contrived program to be strictly conforming even if no implementation other than the aforementioned contrived one could process it correctly.Preshrunk
Given the above two major limitations in the Standard, what practical difference would or should there be between normative and non-normative parts of the Standard? If the Standard doesn't require that a conforming implementation be capable of running any useful programs, it would follow that any useful program must impose demands upon an implementation beyond those it would be required to support.Preshrunk
@Preshrunk I don't agree with you that there are two major limitations to the Standard and that conforming implementations would ever not be useful. Non-normative parts are for clarification, the normative parts are, well, normative. Anything else is part of the quality of implementation. Complain to your vendor if their implementation is "trolling" the spec.Umlaut
Are you saying that quality implementations should not be particularly expected to comply with non-normative parts when practical?Preshrunk
@Preshrunk making distinctions between normative and non-normative sections very important: one example is the "type punning", which is allowed in the footnote 95 (C11), however, does not appear anywhere else in the standard, right? However, it turns out that: "In ISO standards, notes are without exception non-normative".Sensorimotor
@pmor: Generally, the parts of a Standard which have normative authority are those where adherence or non-adherence would affect something's conformance category. So far as I can tell, the only situations where the Standard has any meaningful normative authority would be if an otherwise-strictly-conforming program does something that would cause it to be conforming but not strictly conforming, or if a program that exercises the N1570 5.2.4.1 translation limits is being processed by an implementation that cannot process any other such program as specified by the Standard.Preshrunk
@pmor: The N1570 definitions of conformance state that if there exists a conforming implementation which accepts some blob of source code, that blob of source code is a "Conforming C Program", and that if there exists at least one source text that exercises the translation limits, and that some program P processes in a manner consistent with the C Standard, then P is a "Conforming C Implementation". The Rationale acknowledges the possibility that one could contrive a "Conforming C Implementation" that "succeeds at being useless", but people are expected to write useful compilers anyhow.Preshrunk
@pmor: When the C and C++ Standards were written, many programs relied upon useful constructs that were widely but not universally supported, and rather than recognizing categories of implementation that were more or less suitable for different kinds of tasks, or making the language unsuitable for such tasks by declaring the constructs illegitimate, the Standard is simply agnostic as to the legitimacy of such constructs, leaving the question of whether to support them or not up to implementers' judgments.Preshrunk
P
1

The way the Standard is written, all that is required for an implementation to be conforming is that it be capable of processing at least one--possibly contrived and useless--program. For any implementation to actually be useful for anything, however, it must go beyond the bare requirements given by the Standard.

While an implementation need not behave in a fashion consistent with the examples to be conforming, implementations which do so should generally be considered superior to those that don't. Whether an implementation that fails to do so should be regarded as being of sufficient quality to be useful for some particular purpose would depend upon the purpose in question and the reason for failure.

Preshrunk answered 10/10, 2018 at 20:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.