Open
Description
I believe the check warns incorrectly in the following cases:
#include <limits>
template <typename T>
constexpr T kMin{std::numeric_limits<T>::min()};
template <int n>
struct X
{
static constexpr int xn{n};
};
$ clang-tidy --checks=-*,bugprone-dynamic-static-initializers foo.hpp -- -fno-threadsafe-statics
589 warnings generated.
/tmp/foo.hpp:4:13: warning: static variable 'kMin' may be dynamically initialized in this header file [bugprone-dynamic-static-initializers]
4 | constexpr T kMin{std::numeric_limits<T>::min()};
| ^
/tmp/foo.hpp:9:24: warning: static variable 'xn' may be dynamically initialized in this header file [bugprone-dynamic-static-initializers]
9 | static constexpr int xn{n};
| ^