sw/inc/ndindex.hxx | 9 +++++++++ 1 file changed, 9 insertions(+) New commits: commit 21e0122310dedf3b33144cc77f880ec51446186b Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Sun May 22 13:50:11 2022 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue Jun 7 17:35:30 2022 +0200
sw: SwNodeIndex GCC12 spurious -Werror=dangling-pointer= It doesn't understand that ~SwNodeIndex() will remove the pointer, which is obfuscated by over-boostified code. In member function ‘void SwNodeIndex::RegisterIndex(SwNodes&)’, inlined from ‘SwNodeIndex::SwNodeIndex(SwNodes&, SwNodeOffset)’ at sw/inc/ndindex.hxx:54:22, inlined from ‘bool SwNodes::InsBoxen(SwTableNode*, SwTableLine*, SwTableBoxFormat*, SwTextFormatColl*, const SfxItemSet*, sal_uInt16, sal_uInt16)’ at sw/source/core/docnode/ndtbl.cxx:301:41: sw/inc/ndindex.hxx:37:31: error: storing the address of local variable ‘aEndIdx’ in ‘*this.SwNodes::m_vIndices’ [-Werror=dangling-pointer=] 37 | rNodes.m_vIndices = this; | ~~~~~~~~~~~~~~~~~~^~~~~~ sw/source/core/docnode/ndtbl.cxx: In member function ‘bool SwNodes::InsBoxen(SwTableNode*, SwTableLine*, SwTableBoxFormat*, SwTextFormatColl*, const SfxItemSet*, sal_uInt16, sal_uInt16)’: sw/source/core/docnode/ndtbl.cxx:301:17: note: ‘aEndIdx’ declared here 301 | SwNodeIndex aEndIdx( *this, nIdxPos ); | ^~~~~~~ sw/source/core/docnode/ndtbl.cxx:301:17: note: ‘<unknown>’ declared here Change-Id: I3f24cd8e3e0b1fd0a0943150d3d83d09f2c984fc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134741 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 486991b8ec2b63324c8cf5a26e9091942c24b3d9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134774 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sw/inc/ndindex.hxx b/sw/inc/ndindex.hxx index 7d03b0bcadaf..64201ac3e1b3 100644 --- a/sw/inc/ndindex.hxx +++ b/sw/inc/ndindex.hxx @@ -36,7 +36,16 @@ class SW_DLLPUBLIC SwNodeIndex final : public sw::Ring<SwNodeIndex> void RegisterIndex( SwNodes& rNodes ) { if(!rNodes.m_vIndices) + { +#if defined(__GNUC__) && __GNUC__ == 12 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdangling-pointer" +#endif rNodes.m_vIndices = this; +#if defined(__GNUC__) && __GNUC__ == 12 +#pragma GCC diagnostic pop +#endif + } MoveTo(rNodes.m_vIndices); } void DeRegisterIndex( SwNodes& rNodes )