...
Code Block |
---|
namespace MyNamespace { int ilength; } namespace MyNamespace { int iwidth; } void f() { MyNamespace::ilength = MyNamespace::iwidth = 12; } |
The standard library introduces the namespace std
for standards-provided declarations such as std::string
, std::vector
, and std::for_each
. However, it is undefined behavior to introduce new declarations in namespace std
except under special circumstances. The C++ Standard, [namespace.std], paragraphs 1 and 2 [ISO/IEC 14882-2014], states the following:
...
Tool | Version | Checker | Description | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Axivion Bauhaus Suite |
| CertC++-DCL58 | ||||||||||||||
CodeSonar |
| LANG.STRUCT.DECL.SNM | Modification of Standard Namespaces | |||||||||||||
Helix QAC |
| C++3180, C++3181, C++3182 | ||||||||||||||
Klocwork |
| CERT.DCL.STD_NS_MODIFIED | ||||||||||||||
Parasoft C/C++test |
| CERT_CPP-DCL58-a | Do not modify the standard namespaces 'std' and 'posix' | |||||||||||||
Polyspace Bug Finder |
| CERT C++: DCL58-CPP | Checks for modification of standard namespaces (rule fully covered) | |||||||||||||
PVS-Studio |
| PRQA QA-C++ | ||||||||||||||
Include Page |
| PRQA QA-C++
| 4032, 4035, 4631 V1061 | |||||||||||||
SonarQube C/C++ Plugin |
| S3470 |
...