Silence spurious -Werror=uninitialized and -Werror=maybe-uninitialized

seen at least with recent GCC 16 trunk,

> In file included from sw/inc/swatrset.hxx:22,
>                  from sw/inc/format.hxx:27,
>                  from sw/inc/fchrfmt.hxx:23,
>                  from sw/inc/txatbase.hxx:33,
>                  from sw/inc/txtfld.hxx:22,
>                  from sw/source/core/txtnode/atrfld.cxx:25:
> In member function ‘SfxPoolItemHolder::operator bool() const’,
>     inlined from ‘const SfxPoolItem& SwTextAttr::GetAttr() const’ at sw/inc/txatbase.hxx:175:5,
>     inlined from ‘SfxPoolItem& SwTextAttr::GetAttr()’ at sw/inc/txatbase.hxx:181:65,
>     inlined from ‘SwTextField::SwTextField(const SfxPoolItemHolder&, sal_Int32, bool)’ at sw/source/core/txtnode/atrfld.cxx:603:70:
> include/svl/itemset.hxx:72:56: error: ‘*(const SfxPoolItemHolder*)((char*)<unknown> + 8).SfxPoolItemHolder::m_pItem’ is used uninitialized [-Werror=uninitialized]
>    72 |     explicit operator bool() const { return nullptr != m_pItem; }
>       |                                                        ^~~~~~~
> In member function ‘bool SfxPoolItemHolder::isDeleted() const’,
>     inlined from ‘const SfxPoolItem* SfxPoolItemHolder::getItem() const’ at include/svl/itemset.hxx:69:42,
>     inlined from ‘const SfxPoolItem& SwTextAttr::GetAttr() const’ at sw/inc/txatbase.hxx:176:28,
>     inlined from ‘SfxPoolItem& SwTextAttr::GetAttr()’ at sw/inc/txatbase.hxx:181:65,
>     inlined from ‘SwTextField::SwTextField(const SfxPoolItemHolder&, sal_Int32, bool)’ at sw/source/core/txtnode/atrfld.cxx:603:70:
> include/svl/itemset.hxx:62:37: error: ‘*(const SfxPoolItemHolder*)((char*)<unknown> + 8).SfxPoolItemHolder::m_bDeleted’ may be used uninitialized [-Werror=maybe-uninitialized]
>    62 |     bool isDeleted() const { return m_bDeleted; }
>       |                                     ^~~~~~~~~~

Change-Id: Id02928cf69afa850f97fe3f1eff958055f2a9302
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197840
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Stephan Bergmann
2026-01-22 22:49:32 +01:00
parent 713e048c23
commit 446f995f86
+8
View File
@@ -600,7 +600,15 @@ SwTextField::SwTextField(
, m_aExpand()
, m_pTextNode( nullptr )
{
#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 16
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#pragma GCC diagnostic ignored "-Wuninitialized"
#endif
SwFormatField& rSwFormatField(static_cast<SwFormatField&>(GetAttr()));
#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 16
#pragma GCC diagnostic pop
#endif
m_aExpand = rSwFormatField.GetField()->ExpandField(bInClipboard, nullptr);
rSwFormatField.SetTextField( *this );
SetHasDummyChar(true);