In the C++ standard, what is specified to occur when a “shall” requirement is violated?

后端 未结 2 1832
予麋鹿
予麋鹿 2021-01-01 15:47

For example, the famous words (§3.2/1)

No translation unit shall contain more than one definition of any variable, function, class type, enumeration

2条回答
  •  悲哀的现实
    2021-01-01 16:21

    In addition to @JerryCoffin's answer, there is also ISO/IEC Directives Part 2 (that governs all ISO/IEC documents, including the C++ Standard), in particular Annex H Verbal forms for the expression of provisions

    The verbal forms shown in Table H.1 shall be used to indicate requirements strictly to be followed in order to conform to the document and from which no deviation is permitted.

    shall:

    • is to,
    • is required to,
    • it is required that,
    • has to,
    • only … is permitted,
    • it is necessary

    shall not:

    • is not allowed [permitted] [acceptable] [permissible],
    • is required to be not
    • is required that … be not
    • is not to be

    So a violation of a "shall" requirement makes a program ill-formed. The diagnostic issues have been answered elsewhere.

提交回复
热议问题