From 95d0e71a652992bcdc0c54844c4c6e5282247c6b Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Wed, 21 Sep 2022 11:20:07 -0400 Subject: [PATCH 1/2] test C++14 on MSVC (#4191) --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 213c69005..fe57e7ce9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -737,6 +737,9 @@ jobs: args: -DCMAKE_CXX_STANDARD=20 - python: 3.8 args: -DCMAKE_CXX_STANDARD=17 + - python: 3.7 + args: -DCMAKE_CXX_STANDARD=14 + name: "🐍 ${{ matrix.python }} • MSVC 2019 • x86 ${{ matrix.args }}" runs-on: windows-2019 From f743bdf8e61b2dc4a8995a0485111bedd9c2cbb1 Mon Sep 17 00:00:00 2001 From: bogdan-lab <60753036+bogdan-lab@users.noreply.github.com> Date: Wed, 21 Sep 2022 21:50:31 +0300 Subject: [PATCH 2/2] Avoid local_internals destruction (#4192) * Avoid local_internals destruction It allows to avoid possible static deinitialization fiasco. * Add link to relevant google style guide discussion --- include/pybind11/detail/internals.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/pybind11/detail/internals.h b/include/pybind11/detail/internals.h index 86991955b..d47084e26 100644 --- a/include/pybind11/detail/internals.h +++ b/include/pybind11/detail/internals.h @@ -514,8 +514,13 @@ struct local_internals { /// Works like `get_internals`, but for things which are locally registered. inline local_internals &get_local_internals() { - static local_internals locals; - return locals; + // Current static can be created in the interpreter finalization routine. If the later will be + // destroyed in another static variable destructor, creation of this static there will cause + // static deinitialization fiasco. In order to avoid it we avoid destruction of the + // local_internals static. One can read more about the problem and current solution here: + // https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables + static auto *locals = new local_internals(); + return *locals; } /// Constructs a std::string with the given arguments, stores it in `internals`, and returns its