Files
2025-10-25 03:02:53 +03:00

215 lines
8.9 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[intro.compliance.general]
# 4 General principles [[intro]](./#intro)
## 4.1 Implementation compliance [[intro.compliance]](intro.compliance#general)
### 4.1.1 General [intro.compliance.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L742)
The set of[*diagnosable rules*](#def:diagnosable_rules "4.1.1General[intro.compliance.general]") consists of all syntactic and semantic rules in this document
except for those rules containing an explicit notation that
“no diagnostic is required” or which are described as resulting in
“undefined behavior”[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L752)
Although this document states only requirements on C++
implementations, those requirements are often easier to understand if
they are phrased as requirements on programs, parts of programs, or
execution of programs[.](#2.sentence-1)
Such requirements have the following meaning:
- [(2.1)](#2.1)
If a program contains no violations of the rules in[[lex]](lex "5Lexical conventions") through [[exec]](exec "33Execution control library") as well as those specified in [[depr]](depr "Annex D(normative)Compatibility features"),
a conforming implementation shall accept and correctly execute[3](#footnote-3 "“Correct execution” can include undefined behavior and erroneous behavior, depending on the data being processed; see [intro.defs] and [intro.execution].") that program,
except when the implementation's limitations (see below) are exceeded[.](#2.1.sentence-1)
- [(2.2)](#2.2)
If a program contains a violation of a rule for which no diagnostic is required,
this document places no requirement on implementations
with respect to that program[.](#2.2.sentence-1)
- [(2.3)](#2.3)
Otherwise, if a program contains
* [(2.3.1)](#2.3.1)
a violation of any diagnosable rule,
* [(2.3.2)](#2.3.2)
a preprocessing translation unit with
a #warning preprocessing directive ([[cpp.error]](cpp.error "15.9Diagnostic directives")),
* [(2.3.3)](#2.3.3)
an occurrence
of a construct described in this document as “conditionally-supported” when
the implementation does not support that construct, or
* [(2.3.4)](#2.3.4)
a contract assertion ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation"))
evaluated with a checking semantic
in a manifestly constant-evaluated context ([[expr.const]](expr.const "7.7Constant expressions"))
resulting in a contract violation,
a conforming implementation
shall issue at least one diagnostic message[.](#2.3.sentence-1)
[*Note [1](#note-1)*:
During template argument deduction and substitution,
certain constructs that in other contexts require a diagnostic
are treated differently;
see [[temp.deduct]](temp.deduct "13.10.3Template argument deduction")[.](#2.sentence-2)
— *end note*]
Furthermore, a conforming implementation
shall not accept
- [(2.4)](#2.4)
a preprocessing translation unit containing
a #error preprocessing directive ([[cpp.error]](cpp.error "15.9Diagnostic directives")),
- [(2.5)](#2.5)
a translation unit with
a [*static_assert-declaration*](dcl.pre#nt:static_assert-declaration "9.1Preamble[dcl.pre]") that fails ([[dcl.pre]](dcl.pre "9.1Preamble")), or
- [(2.6)](#2.6)
a contract assertion evaluated with a terminating semantic ([[basic.contract.eval]](basic.contract.eval "6.11.2Evaluation"))
in a manifestly constant-evaluated context ([[expr.const]](expr.const "7.7Constant expressions"))
resulting in a contract violation[.](#2.sentence-3)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L821)
For classes and class templates, the library Clauses specify partial
definitions[.](#3.sentence-1)
[Private members](class.access "11.8Member access control[class.access]") are not
specified, but each implementation shall supply them to complete the
definitions according to the description in the library Clauses[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L830)
For functions, function templates, objects, and values, the library
Clauses specify declarations[.](#4.sentence-1)
Implementations shall supply definitions
consistent with the descriptions in the library Clauses[.](#4.sentence-2)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L835)
A C++ translation unit ([[lex.phases]](lex.phases "5.2Phases of translation"))
obtains access to the names defined in the library by
including the appropriate standard library header or importing
the appropriate standard library named header unit ([[using.headers]](using.headers "16.4.3.2Headers"))[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L841)
The templates, classes, functions, and objects in the library have
external [linkage](basic.link "6.7Program and linkage[basic.link]")[.](#6.sentence-1)
The implementation provides
definitions for standard library entities, as necessary, while combining
translation units to form a complete C++ program ([[lex.phases]](lex.phases "5.2Phases of translation"))[.](#6.sentence-2)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L848)
An implementation is either a[*hosted implementation*](#def:implementation,hosted "4.1.1General[intro.compliance.general]") or a[*freestanding implementation*](#def:implementation,freestanding "4.1.1General[intro.compliance.general]")[.](#7.sentence-1)
A freestanding
implementation is one in which execution may take place without the benefit of
an operating system[.](#7.sentence-2)
A hosted implementation
supports all the facilities described in this document, while
a freestanding implementation
supports the entire C++ language
described in [[lex]](lex "5Lexical conventions") through [[cpp]](cpp "15Preprocessing directives") and
the subset of the library facilities described in [[compliance]](compliance "16.4.2.5Freestanding implementations")[.](#7.sentence-3)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L862)
It isimplementation-defined
whether the implementation is a[*hardened implementation*](#def:implementation,hardened "4.1.1General[intro.compliance.general]")[.](#8.sentence-1)
If it is a hardened implementation,
violating a hardened precondition
results in a contract violation ([[structure.specifications]](structure.specifications "16.3.2.4Detailed specifications"))[.](#8.sentence-2)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L871)
An implementation is encouraged to document its limitations in
the size or complexity of the programs it can successfully process,
if possible and where known[.](#9.sentence-1)
[[implimits]](implimits "Annex B(informative)Implementation quantities") lists some quantities that can be subject to limitations and
a potential minimum supported value for each quantity[.](#9.sentence-2)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L878)
A conforming implementation may use an implementation-defined version
of the Unicode Standard that is a later version than the one
referenced in [[intro.refs]](intro.refs "2Normative references")[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L883)
A conforming implementation may have extensions (including
additional library functions), provided they do not alter the
behavior of any well-formed program[.](#11.sentence-1)
Implementations are required to diagnose programs that use such
extensions that are ill-formed according to this document[.](#11.sentence-2)
Having done so, however, they can compile and execute such programs[.](#11.sentence-3)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L891)
Each implementation shall include documentation that identifies all
conditionally-supported constructs that it does not support and defines all locale-specific characteristics[.](#12.sentence-1)[4](#footnote-4 "This documentation also defines implementation-defined behavior; see [intro.abstract].")
[3)](#footnote-3)[3)](#footnoteref-3)
“Correct execution” can include undefined behavior
and erroneous behavior, depending on
the data being processed; see [[intro.defs]](intro.defs "3Terms and definitions") and [[intro.execution]](intro.execution "6.10.1Sequential execution")[.](#footnote-3.sentence-1)
[4)](#footnote-4)[4)](#footnoteref-4)
This documentation also defines implementation-defined behavior;
see [[intro.abstract]](intro.abstract "4.1.2Abstract machine")[.](#footnote-4.sentence-1)