Open
Description
C++17 suggests us the possibility to use inline
on constexpr
variables, but pre-C++17 codebases (or code unaware of this rule) often omit inline in headers. This can silently bloat binaries and harm performance due to multiple symbol definitions.
Need a check to enforce inline
on constexpr
variables in header files.
BEFORE:
// header.h
constexpr int MAX_SIZE = 1024;
AFTER:
// header.h
inline constexpr int MAX_SIZE = 1024;
Scope
- Applies only to headers (.h, .hpp, etc.), ignoring .cpp files.
- Targets
constexpr
variables in global/namespace scope (not function locals).
Why performance-
?
- Binary size (reduces duplicate symbols).
- Cache behavior (fewer redundant constants in memory).