Attributes provide a standardized syntax for conveying implementation-defined language extensions and hints to the compiler. While the {C++}
standard defines several attributes (such as [[deprecated]], [[maybe_unused]], and [[nodiscard]]), compilers
also support vendor-specific attributes for compiler-specific features and optimizations.
Using non-standard attributes introduces portability risks. When code with compiler-specific attributes is compiled with a different toolchain,
unrecognized attributes are silently ignored, which can lead to:
- Loss of intended behavior (e.g., optimization hints, alignment requirements, or safety checks)
- Runtime failures when the ignored attribute was critical for correctness
- Maintenance burden when vendor-specific attributes are scattered across the codebase
This rule allows only standard attributes that are specified using the standard [[...]] syntax. It reports: * All attributes that are
not defined in the {C++} standard itself, whether expressed using standard attribute syntax with vendor namespaces (e.g.,
[[msvc::no_unique_address]]), GNU-style __attribute__ syntax (e.g., __attribute__((packed))), or MSVC’s
__declspec syntax (e.g., __declspec(align(16))) * Standard attributes that are specified using non-standard syntax (e.g.,
__attribute__((noreturn)) instead of [[noreturn]])
The goal is to ensure that such attributes are reviewed to be well-behaved under all used toolchains, or replaced with standard-conforming
alternatives when possible.