[clang-tools-extra] [clang-tidy] Fix false positive in `bugprone-std-namespace-modification` when opening subnamespaces of `std::` (PR #174170)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 2 07:05:06 PST 2026
localspook wrote:
It looks like using an inline namespace is exactly what libc++ does. But even with libc++, the following code compiles just fine (https://godbolt.org/z/PYz5aafvv):
```cpp
#include <ranges>
struct MyClass1 {};
struct MyClass2 {};
namespace std::ranges {
template <> constexpr bool enable_view<MyClass1> = true;
}
namespace std { namespace ranges {
template <> constexpr bool enable_view<MyClass2> = true;
} }
```
Is this guaranteed to work by the standard? If not, it seems like a really unexpected footgun
https://github.com/llvm/llvm-project/pull/174170
More information about the cfe-commits
mailing list