Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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::stringstd::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:

...

 PRQA QA-C++PRQA QA-C++4032, 4035, 4631 

Tool

Version

Checker

Description

Axivion Bauhaus Suite

Include Page
Axivion Bauhaus Suite_V
Axivion Bauhaus Suite_V

CertC++-DCL58
CodeSonar
Include Page
CodeSonar_V
CodeSonar_V

LANG.STRUCT.DECL.SNM

Modification of Standard Namespaces

Helix QAC

Include Page
Helix QAC_V
Helix QAC_V

C++3180, C++3181, C++3182


Klocwork
Include Page
Klocwork_V
Klocwork_V
CERT.DCL.STD_NS_MODIFIED 
Parasoft C/C++test

Include Page
Parasoft_V
Parasoft_V

CERT_CPP-DCL58-a

Do not modify the standard namespaces 'std' and 'posix'
Polyspace Bug Finder

Include Page
Polyspace Bug Finder_V
Polyspace Bug Finder_V

CERT C++: DCL58-CPPChecks for modification of standard namespaces (rule fully covered)
PVS-Studio

Include Page
PVS-Studio

PRQA QA-C++
Include Page

_V

PVS-Studio_V

V1061
SonarQube C/C++ Plugin
Include Page
SonarQube C/C++ Plugin_V
SonarQube C/C++ Plugin_V
S3470

...