[clang-tools-extra] [clang-tidy] Fix false positive in `bugprone-std-namespace-modification` when opening subnamespaces of `std::` (PR #174170)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 2 03:47:26 PST 2026
https://github.com/zwuis requested changes to this pull request.
> https://github.com/cplusplus/draft/issues/8714
>
> ~~TL;DR: Reopening pre-existing namespaces is ok.~~
Sorry that I misread the discussion. Reopening namespaces in `std` is UB.
```cpp
// possible library implementation
namespace std {
inline namespace __v1 {
namespace ranges { /* enable_view */ }
}
}
// user code
namespace std::ranges {} // This is not __v1::ranges
namespace std {
// ok but we can add an option to emit warnings
template <>
constexpr bool ranges::enable_view<MyClass> = true;
}
```
https://github.com/llvm/llvm-project/pull/174170
More information about the cfe-commits
mailing list