Open
Description
C++17 suggests us the possibility to use inline
on constexpr
variables, but when identical inline constexpr
variables are defined in different translation units with different values, this violates the One Definition Rule (ODR) which manifests unpredictably (e.g., different values in different TUs).
Need a check to get rid from inline
keyword on constexpr
variables in source files.
BEFORE:
// foo.cpp
inline constexpr int MAX_SIZE = 1024;
AFTER:
// foo.cpp
constexpr int MAX_SIZE = 1024;
Scope
- Applies only to sources (.cpp, .cxx, etc.), ignoring .h files.
Why bugprone-
?
- Runtime behaviour potentially affected due to unexpected constant's value selected in link time.