rspec/rules/S829/rule.adoc
Arseniy Zaostrovnykh 7ca29f686f Force linebreaks
2021-02-02 15:02:10 +01:00

47 lines
997 B
Plaintext

Violation of the One Definition Rule (ISO/IEC 14882:2003, §3.2) leads to undefined behaviour. In general, this means that the program shall contain exactly one definition of every non-inline function or object.
Additionally:
* The definitions of a type shall consist of the same sequence of tokens, and;
* The definitions of a template shall consist of the same sequence of tokens, and;
* The definitions of an inline function shall consist of the same sequence of tokens.
Note that for the purposes of this rule, typedefs shall be treated as types.
== Noncompliant Code Example
----
// File a.cpp
struct S1
{
int32_t i;
};
struct S2
{
int32_t i;
};
// File b.cpp
struct S1
{
int64_t i;
}; // Noncompliant, token sequence different
struct S2
{
int32_t i;
int32_t j;
}; // Noncompliant, token sequence different
----
== See
* MISRA {cpp}:2008, 3-2-2
* ISO/IEC 14882:2003, §3.2
* https://wiki.sei.cmu.edu/confluence/x/IXs-BQ[CERT, DCL60-CPP.] - Obey the one-definition rule