[PATCH] D62829: [clang-tidy] Check for dynamically initialized statics in headers.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 23 08:27:16 PDT 2019


aaron.ballman added inline comments.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-dynamic-static-initializers.rst:9
+
+This can pose problems in certain multithreaded contexts.
----------------
Eugene.Zelenko wrote:
> Will be good idea to provide example.
Agreed, I'd like to see an example in the docs.


================
Comment at: clang-tools-extra/test/clang-tidy/bugprone-dynamic-static-initializers.hpp:33-35
+  // This may work fine when optimization is enabled because bar() can
+  // be turned into a constant 7.  But without optimization, it can
+  // cause problems. Therefore, we must err on the side of conservatism.
----------------
What problems can be caused here? Typically, dynamic init is only problematic when it happens before main() is executed (because of initialization order dependencies), but that doesn't apply to local statics.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62829/new/

https://reviews.llvm.org/D62829





More information about the cfe-commits mailing list