From e654460418bc19be548ab2634d43ed370453fa5c Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 7 Aug 2022 21:49:37 -0700 Subject: [PATCH] Disable mingw warning. ``` cd /d D:\a\pybind11\pybind11\build3\tests && D:\a\_temp\msys64\mingw64\bin\c++.exe -DPYBIND11_ENABLE_TYPE_CASTER_ODR_GUARD_IF_AVAILABLE -DPYBIND11_TEST_BOOST -DPYBIND11_TEST_EIGEN -Dpybind11_tests_EXPORTS @CMakeFiles/pybind11_tests.dir/includes_CXX.rsp -Os -DNDEBUG -fvisibility=hidden -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated -Wundef -Wnon-virtual-dtor -Werror -std=c++17 -MD -MT tests/CMakeFiles/pybind11_tests.dir/test_stl.cpp.obj -MF CMakeFiles\pybind11_tests.dir\test_stl.cpp.obj.d -o CMakeFiles\pybind11_tests.dir\test_stl.cpp.obj -c D:\a\pybind11\pybind11\tests\test_stl.cpp In file included from D:/a/pybind11/pybind11/include/pybind11/stl.h:32, from D:\a\pybind11\pybind11\tests\test_stl.cpp:10: In member function 'std::enable_if_t<((__exactly_once::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type> > && is_constructible_v::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>, _Tp>) && is_assignable_v::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>&, _Tp>), std::variant<_Types>&> std::variant<_Types>::operator=(_Tp&&) [with _Tp = std::nullptr_t; _Types = {int, std::__cxx11::basic_string, std::allocator >, double, std::nullptr_t}]', inlined from 'std::enable_if_t<((__exactly_once::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type> > && is_constructible_v::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>, _Tp>) && is_assignable_v::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>&, _Tp>), std::variant<_Types>&> std::variant<_Types>::operator=(_Tp&&) [with _Tp = std::nullptr_t; _Types = {int, std::__cxx11::basic_string, std::allocator >, double, std::nullptr_t}]' at D:/a/_temp/msys64/mingw64/include/c++/12.1.0/variant:1469:2, inlined from 'bool pybind11::detail::variant_caster >::load_alternative(pybind11::handle, bool, pybind11::detail::type_list) [with U = std::nullptr_t; Us = {}; V = std::variant; Ts = {int, std::__cxx11::basic_string, std::allocator >, double, std::nullptr_t}]' at D:/a/pybind11/pybind11/include/pybind11/stl.h:375:19, inlined from 'bool pybind11::detail::variant_caster >::load_alternative(pybind11::handle, bool, pybind11::detail::type_list) [with U = double; Us = {std::nullptr_t}; V = std::variant; Ts = {int, std::__cxx11::basic_string, std::allocator >, double, std::nullptr_t}]' at D:/a/pybind11/pybind11/include/pybind11/stl.h:378:32, inlined from 'bool pybind11::detail::variant_caster >::load_alternative(pybind11::handle, bool, pybind11::detail::type_list) [with U = std::__cxx11::basic_string; Us = {double, std::nullptr_t}; V = std::variant; Ts = {int, std::__cxx11::basic_string, std::allocator >, double, std::nullptr_t}]' at D:/a/pybind11/pybind11/include/pybind11/stl.h:378:32, inlined from 'bool pybind11::detail::variant_caster >::load_alternative(pybind11::handle, bool, pybind11::detail::type_list) [with U = int; Us = {std::__cxx11::basic_string, std::allocator >, double, std::nullptr_t}; V = std::variant; Ts = {int, std::__cxx11::basic_string, std::allocator >, double, std::nullptr_t}]' at D:/a/pybind11/pybind11/include/pybind11/stl.h:378:32: D:/a/_temp/msys64/mingw64/include/c++/12.1.0/variant:1475:38: error: 'caster.pybind11::detail::type_caster_odr_guard >::.pybind11::detail::type_caster::.pybind11::detail::void_caster::value' may be used uninitialized [-Werror=maybe-uninitialized] 1475 | std::get<__index>(*this) = std::forward<_Tp>(__rhs); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ D:/a/pybind11/pybind11/include/pybind11/stl.h: In function 'bool pybind11::detail::variant_caster >::load_alternative(pybind11::handle, bool, pybind11::detail::type_list) [with U = int; Us = {std::__cxx11::basic_string, std::allocator >, double, std::nullptr_t}; V = std::variant; Ts = {int, std::__cxx11::basic_string, std::allocator >, double, std::nullptr_t}]': D:/a/pybind11/pybind11/include/pybind11/stl.h:373:14: note: 'caster.pybind11::detail::type_caster_odr_guard >::.pybind11::detail::type_caster::.pybind11::detail::void_caster::value' was declared here 373 | auto caster = make_caster(); | ^~~~~~ cc1plus.exe: all warnings being treated as errors ``` --- include/pybind11/stl.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index ab30ecac0..8710de014 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -370,12 +370,19 @@ struct variant_caster> { template bool load_alternative(handle src, bool convert, type_list) { +#if defined(__MINGW32__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif auto caster = make_caster(); if (caster.load(src, convert)) { value = cast_op(std::move(caster)); return true; } return load_alternative(src, convert, type_list{}); +#if defined(__MINGW32__) +# pragma GCC diagnostic pop +#endif } bool load_alternative(handle, bool, type_list<>) { return false; }