Silence strange -Wmaybe-uninitialized with recent GCC 14

...seen at least with some (--enable-dbgutil --enable-otpimized etc.)
configuration and a recent GCC 14 trunk,

> In file included from ~/gcc/inst/include/c++/14.0.1/vector:66,
>                  from include/unotools/options.hxx:26,
>                  from include/unotools/lingucfg.hxx:27,
>                  from linguistic/source/lngsvcmgr.cxx:35:
> In destructor ‘constexpr std::__cxx1998::vector< <template-parameter-1-1>, <template-parameter-1-2> >::~vector() [with _Tp = SvcInfo; _Alloc = std::allocator<SvcInfo>]’,
>     inlined from ‘constexpr std::__debug::vector<_Tp, _Allocator>::~vector() [with _Tp = SvcInfo; _Allocator = std::allocator<SvcInfo>]’ at ~/gcc/inst/include/c++/14.0.1/debug/vector:245:7,
>     inlined from ‘constexpr void std::_Optional_payload_base<_Tp>::_M_destroy() [with _Tp = std::__debug::vector<SvcInfo>]’ at ~/gcc/inst/include/c++/14.0.1/optional:283:35,
>     inlined from ‘constexpr void std::_Optional_payload_base<_Tp>::_M_reset() [with _Tp = std::__debug::vector<SvcInfo>]’ at ~/gcc/inst/include/c++/14.0.1/optional:314:14,
>     inlined from ‘constexpr std::_Optional_payload<_Tp, false, _Copy, _Move>::~_Optional_payload() [with _Tp = std::__debug::vector<SvcInfo>; bool _Copy = false; bool _Move = false]’ at ~/gcc/inst/include/c++/14.0.1/optional:437:65,
>     inlined from ‘constexpr std::_Optional_base<std::__debug::vector<SvcInfo>, false, false>::~_Optional_base()’ at ~/gcc/inst/include/c++/14.0.1/optional:508:12,
>     inlined from ‘constexpr std::optional<std::__debug::vector<SvcInfo> >::~optional()’ at ~/gcc/inst/include/c++/14.0.1/optional:703:11,
>     inlined from ‘LngSvcMgr::~LngSvcMgr()’ at linguistic/source/lngsvcmgr.cxx:519:1:
> ~/gcc/inst/include/c++/14.0.1/bits/stl_vector.h:735:22: error: ‘((std::__cxx1998::vector<SvcInfo, std::allocator<SvcInfo> >*)((char*)this + 16))[22].std::__cxx1998::vector<SvcInfo, std::allocator<SvcInfo> >::std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_M_impl.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl::std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl_data.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl_data::_M_finish’ may be used uninitialized [-Werror=maybe-uninitialized]
>   735 |         std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
>       |         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   736 |                       _M_get_Tp_allocator());
>       |                       ~~~~~~~~~~~~~~~~~~~~~~
> ~/gcc/inst/include/c++/14.0.1/bits/stl_vector.h:735:22: error: ‘((std::__cxx1998::vector<SvcInfo, std::allocator<SvcInfo> >*)((char*)this + 16))[22].std::__cxx1998::vector<SvcInfo, std::allocator<SvcInfo> >::std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_M_impl.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl::std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl_data.std::__cxx1998::_Vector_base<SvcInfo, std::allocator<SvcInfo> >::_Vector_impl_data::_M_start’ may be used uninitialized [-Werror=maybe-uninitialized]

Change-Id: I02815c39ee6026b4637a4bb6ad2804af7a446a57
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165821
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
This commit is contained in:
Stephan Bergmann 2024-04-05 16:43:08 +02:00
parent 2bcd9fe0fa
commit 745ba22017

View file

@ -504,6 +504,10 @@ void LngSvcMgr::disposing(const lang::EventObject&)
stopListening();
}
#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 14
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
LngSvcMgr::~LngSvcMgr()
{
stopListening();
@ -517,6 +521,9 @@ LngSvcMgr::~LngSvcMgr()
pAvailHyphSvcs.reset();
pAvailThesSvcs.reset();
}
#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 14
#pragma GCC diagnostic pop
#endif
namespace
{