...
Defining an unnamed namespace within a header file can cause data integrity violations and performance problems but is unlikely to go unnoticed with sufficient testing. One-definition rule violations result in undefined behavior.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL59-CPP | Medium | Unlikely | Medium | P4 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Astrée |
| unnamed-namespace-header | Fully checked | ||||||
Axivion Bauhaus Suite |
| CertC++-DCL59 | |||||||
Clang |
| cert-dcl59-cpp | Checked by clang-tidy | ||||||
CodeSonar |
| LANG.STRUCT.DECL.ANH | Anonymous Namespace in Header File | ||||||
Helix QAC |
| C++2518 | |||||||
Klocwork |
| MISRA.NAMESPACE.UNMD | |||||||
LDRA tool suite |
| 286 S, 512 S | Fully implemented | ||||||
Parasoft C/C++test |
|
|
CERT_CPP-DCL59-a | There shall be no unnamed namespaces in header files | ||||||||
Polyspace Bug Finder |
| CERT C++: DCL59-CPP | Checks for unnamed namespaces in header files (rule fully covered) | ||||||
RuleChecker |
| unnamed-namespace-header | Fully checked | ||||||
SonarQube C/C++ Plugin |
| UnnamedNamespaceInHeader |
PVS-Studio |
|
|
|
2518
V1068 |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
Bibliography
[ISO/IEC 14882-2014] | Subclause 3.2, "One Definition Rule" |
...
...