Skip to content

Add -DPYBIND11_WERROR=ON to mingw cmake commands #4073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 1, 2022
Merged
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ jobs:
- name: Configure C++11
# LTO leads to many undefined reference like
# `pybind11::detail::function_call::function_call(pybind11::detail::function_call&&)
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DDOWNLOAD_CATCH=ON -S . -B build
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build

- name: Build C++11
run: cmake --build build -j 2
Expand All @@ -929,7 +929,7 @@ jobs:
run: git clean -fdx

- name: Configure C++14
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DDOWNLOAD_CATCH=ON -S . -B build2
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build2

- name: Build C++14
run: cmake --build build2 -j 2
Expand All @@ -947,7 +947,7 @@ jobs:
run: git clean -fdx

- name: Configure C++17
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DDOWNLOAD_CATCH=ON -S . -B build3
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build3

- name: Build C++17
run: cmake --build build3 -j 2
Expand Down
5 changes: 5 additions & 0 deletions include/pybind11/eigen.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@
# pragma warning(disable : 4127) // C4127: conditional expression is constant
# pragma warning(disable : 5054) // https://github.com/pybind/pybind11/pull/3741
// C5054: operator '&': deprecated between enumerations of different types
#elif defined(__MINGW32__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif

#include <Eigen/Core>
#include <Eigen/SparseCore>

#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__MINGW32__)
# pragma GCC diagnostic pop
#endif

// Eigen prior to 3.2.7 doesn't have proper move constructors--but worse, some classes get implicit
Expand Down
9 changes: 7 additions & 2 deletions tests/test_builtin_casters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,14 @@ TEST_SUBMODULE(builtin_casters, m) {
});
m.def("lvalue_nested", []() -> const decltype(lvnested) & { return lvnested; });

static std::pair<int, std::string> int_string_pair{2, "items"};
m.def(
"int_string_pair", []() { return &int_string_pair; }, py::return_value_policy::reference);
"int_string_pair",
[]() {
// Using no-destructor idiom to side-step warnings from overzealous compilers.
static auto *int_string_pair = new std::pair<int, std::string>{2, "items"};
return int_string_pair;
},
py::return_value_policy::reference);

// test_builtins_cast_return_none
m.def("return_none_string", []() -> std::string * { return nullptr; });
Expand Down
10 changes: 8 additions & 2 deletions tests/test_stl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,14 @@ TEST_SUBMODULE(stl, m) {
m.def("load_bool_vector",
[](const std::vector<bool> &v) { return v.at(0) == true && v.at(1) == false; });
// Unnumbered regression (caused by #936): pointers to stl containers aren't castable
static std::vector<RValueCaster> lvv{2};
m.def(
"cast_ptr_vector", []() { return &lvv; }, py::return_value_policy::reference);
"cast_ptr_vector",
[]() {
// Using no-destructor idiom to side-step warnings from overzealous compilers.
static auto *v = new std::vector<RValueCaster>{2};
return v;
},
py::return_value_policy::reference);

// test_deque
m.def("cast_deque", []() { return std::deque<int>{1}; });
Expand Down Expand Up @@ -237,6 +242,7 @@ TEST_SUBMODULE(stl, m) {
lvn["b"].emplace_back(); // add a list
lvn["b"].back().emplace_back(); // add an array
lvn["b"].back().emplace_back(); // add another array
static std::vector<RValueCaster> lvv{2};
m.def("cast_lv_vector", []() -> const decltype(lvv) & { return lvv; });
m.def("cast_lv_array", []() -> const decltype(lva) & { return lva; });
m.def("cast_lv_map", []() -> const decltype(lvm) & { return lvm; });
Expand Down