rttrorg / rttr

C++ Reflection Library
https://www.rttr.org
MIT License
3.2k stars 444 forks source link

warning: '<anonymous>' may be used uninitialized #357

Open kwizart opened 1 year ago

kwizart commented 1 year ago

With recent c++ ( and for now only on ppc64le and s390x, but that might be an hidden error on others arches). I have the following build warning (treated as error because of -Werror=maybe-uninitialized).

Reproduced when building under fedora-38+

In file included from /usr/include/c++/13/functional:59,
                 from /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/detail/misc/function_traits.h:36,
                 from /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/detail/misc/misc_type_traits.h:33,
                 from /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/detail/misc/utility.h:34,
                 from /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/detail/impl/string_view_impl.h:32,
                 from /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/string_view.h:498,
                 from /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/type.h:32,
                 from /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/type.cpp:28:
In member function 'std::function<bool (rttr::property const&)>::function(std::function<bool (rttr::property const&)> const&)',
    inlined from 'rttr::detail::default_predicate<rttr::property>::default_predicate(rttr::detail::default_predicate<rttr::property> const&)' at /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/detail/impl/array_range_impl.h:511:8,
    inlined from 'rttr::array_range<rttr::property, rttr::detail::default_predicate<rttr::property> >::array_range(rttr::property const*, unsigned long, rttr::detail::default_predicate<rttr::property> const&)' at /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/detail/impl/array_range_impl.h:45:5,
    inlined from 'rttr::type::get_properties() const' at /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/type.cpp:276:41:
/usr/include/c++/13/bits/std_function.h:391:17: error: '<anonymous>' may be used uninitialized [-Werror=maybe-uninitialized]
  391 |             __x._M_manager(_M_functor, __x._M_functor, __clone_functor);
      |             ~~~~^~~~~~~~~~
/usr/include/c++/13/bits/std_function.h: In member function 'rttr::type::get_properties() const':
/usr/include/c++/13/bits/std_function.h:267:7: note: by argument 2 of type 'const union _Any_data & {ref-all}' to 'std::_Function_handler<bool (rttr::property const&), rttr::type::get_properties() const::{lambda(rttr::property const&)#1}>::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation)' declared here
  267 |       _M_manager(_Any_data& __dest, const _Any_data& __source,
      |       ^~~~~~~~~~
/builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/type.cpp:276:39: note: '<anonymous>' declared here
  276 |                                      }) );
      |                                       ^
In member function 'std::function<bool (rttr::method const&)>::function(std::function<bool (rttr::method const&)> const&)',
    inlined from 'rttr::detail::default_predicate<rttr::method>::default_predicate(rttr::detail::default_predicate<rttr::method> const&)' at /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/detail/impl/array_range_impl.h:511:8,
    inlined from 'rttr::array_range<rttr::method, rttr::detail::default_predicate<rttr::method> >::array_range(rttr::method const*, unsigned long, rttr::detail::default_predicate<rttr::method> const&)' at /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/detail/impl/array_range_impl.h:45:5,
    inlined from 'rttr::type::get_methods() const' at /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/type.cpp:345:39:
/usr/include/c++/13/bits/std_function.h:391:17: error: '<anonymous>' may be used uninitialized [-Werror=maybe-uninitialized]
  391 |             __x._M_manager(_M_functor, __x._M_functor, __clone_functor);
      |             ~~~~^~~~~~~~~~
/usr/include/c++/13/bits/std_function.h: In member function 'rttr::type::get_methods() const':
/usr/include/c++/13/bits/std_function.h:267:7: note: by argument 2 of type 'const union _Any_data & {ref-all}' to 'std::_Function_handler<bool (rttr::method const&), rttr::type::get_methods() const::{lambda(rttr::method const&)#1}>::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation)' declared here
  267 |       _M_manager(_Any_data& __dest, const _Any_data& __source,
      |       ^~~~~~~~~~
/builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/type.cpp:345:37: note: '<anonymous>' declared here
  345 |                                    }) );
      |                                     ^
In member function 'std::function<bool (rttr::constructor const&)>::function(std::function<bool (rttr::constructor const&)> const&)',
    inlined from 'rttr::detail::default_predicate<rttr::constructor>::default_predicate(rttr::detail::default_predicate<rttr::constructor> const&)' at /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/detail/impl/array_range_impl.h:511:8,
    inlined from 'rttr::array_range<rttr::constructor, rttr::detail::default_predicate<rttr::constructor> >::array_range(rttr::constructor const*, unsigned long, rttr::detail::default_predicate<rttr::constructor> const&)' at /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/../rttr/detail/impl/array_range_impl.h:45:5,
    inlined from 'rttr::type::get_constructors() const' at /builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/type.cpp:534:44:
/usr/include/c++/13/bits/std_function.h:391:17: error: '<anonymous>' may be used uninitialized [-Werror=maybe-uninitialized]
  391 |             __x._M_manager(_M_functor, __x._M_functor, __clone_functor);
      |             ~~~~^~~~~~~~~~
/usr/include/c++/13/bits/std_function.h: In member function 'rttr::type::get_constructors() const':
/usr/include/c++/13/bits/std_function.h:267:7: note: by argument 2 of type 'const union _Any_data & {ref-all}' to 'std::_Function_handler<bool (rttr::constructor const&), rttr::type::get_constructors() const::{lambda(rttr::constructor const&)#1}>::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation)' declared here
  267 |       _M_manager(_Any_data& __dest, const _Any_data& __source,
      |       ^~~~~~~~~~
/builddir/build/BUILD/rttr-7edbd580cfad509a3253c733e70144e36f02ecd4/src/rttr/type.cpp:534:42: note: '<anonymous>' declared here
  534 |                                         }) );
btgoodwin commented 1 year ago

Same issue here when building under Yocto Poky 4.2.2 Mickledore. This is likely related to the more recent compiler version. I see you're on 13; my build is on 12.3.