CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
69 lines
2.3 KiB
ReStructuredText
69 lines
2.3 KiB
ReStructuredText
.. title:: clang-tidy - bugprone-std-namespace-modification
|
|
|
|
bugprone-std-namespace-modification
|
|
===================================
|
|
|
|
Warns on modifications of the ``std`` or ``posix`` namespaces which can
|
|
result in undefined behavior.
|
|
|
|
The ``std`` (or ``posix``) namespace is allowed to be extended with (class or
|
|
function) template specializations that depend on an user-defined type (a type
|
|
that is not defined in the standard system headers).
|
|
|
|
The check detects the following (user provided) declarations in namespace
|
|
``std`` or ``posix``:
|
|
|
|
- Anything that is not a template specialization.
|
|
- Explicit specializations of any standard library function template or class
|
|
template, if it does not have any user-defined type as template argument.
|
|
- Explicit specializations of any member function of a standard library class
|
|
template.
|
|
- Explicit specializations of any member function template of a standard
|
|
library class or class template.
|
|
- Explicit or partial specialization of any member class template of a standard
|
|
library class or class template.
|
|
|
|
Examples:
|
|
|
|
.. code-block:: c++
|
|
|
|
namespace std {
|
|
int x; // warning: modification of 'std' namespace can result in undefined behavior [bugprone-dont-modify-std-namespace]
|
|
}
|
|
|
|
namespace posix::a { // warning: modification of 'posix' namespace can result in undefined behavior
|
|
}
|
|
|
|
template <>
|
|
struct ::std::hash<long> { // warning: modification of 'std' namespace can result in undefined behavior
|
|
unsigned long operator()(const long &K) const {
|
|
return K;
|
|
}
|
|
};
|
|
|
|
struct MyData { long data; };
|
|
|
|
template <>
|
|
struct ::std::hash<MyData> { // no warning: specialization with user-defined type
|
|
unsigned long operator()(const MyData &K) const {
|
|
return K.data;
|
|
}
|
|
};
|
|
|
|
namespace std {
|
|
template <>
|
|
void swap<bool>(bool &a, bool &b); // warning: modification of 'std' namespace can result in undefined behavior
|
|
|
|
template <>
|
|
bool less<void>::operator()<MyData &&, MyData &&>(MyData &&, MyData &&) const { // warning: modification of 'std' namespace can result in undefined behavior
|
|
return true;
|
|
}
|
|
}
|
|
|
|
References
|
|
----------
|
|
|
|
This check corresponds to the CERT C++ Coding Standard rule
|
|
`DCL58-CPP. Do not modify the standard namespaces
|
|
<https://www.securecoding.cert.org/confluence/display/cplusplus/DCL58-CPP.+Do+not+modify+the+standard+namespaces>`_.
|