C & C++

C & C++

Made by DeepSource

Modify namespace std or posix is an undefined behavior CXX-W2017

Bug risk
Major

In C++, one can limit a declaration to the namespace to avoid name resolution conflicts. Also, a namespace declaration is not limited to a single file. This opens up the opportunity to modify the namespace introduced by the standard C++ library namely std and posix. According to the standard, such a modification is an undefined behavior.

Avoid adding declaration or definition to namespace std or namespace posix.

Bad practice

namespace std {
  class User;
}

Recommended

namespace local {
  class User;
}

References