sc/source/core/tool/scmatrix.cxx |    7 +++++++
 svl/source/misc/gridprinter.cxx  |    7 +++++++
 sw/source/core/doc/doc.cxx       |   10 ++++++++++
 3 files changed, 24 insertions(+)

New commits:
commit 5d0e1414295d59605e17a1194bde43b46acd5d71
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Aug 2 10:48:31 2023 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Thu Feb 22 09:51:44 2024 +0100

    Silence some bogus -Werror=array-bounds etc. with GCC 12 and -std=c++20
    
    ...as witnessed with patch set 1 of
    <https://gerrit.libreoffice.org/c/core/+/155121/1> "Bump baseline to C++20",
    
    > In file included from 
/opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/char_traits.h:46,
    >                  from 
/opt/rh/gcc-toolset-12/root/usr/include/c++/12/ios:40,
    >                  from 
/opt/rh/gcc-toolset-12/root/usr/include/c++/12/ostream:38,
    >                  from 
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/include/rtl/ustring.hxx:34,
    >                  from 
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/include/svl/gridprinter.hxx:13,
    >                  from 
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/svl/source/misc/gridprinter.cxx:10:
    > In function ‘constexpr decltype (::new(void*(0)) _Tp) 
std::construct_at(_Tp*, _Args&& ...) [with _Tp = long unsigned int; _Args = 
{const long unsigned int&}]’,
    >     inlined from ‘static constexpr void 
std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, 
_Up*, _Args&& ...) [with _Up = long unsigned int; _Args = {const long unsigned 
int&}; _Tp = long unsigned int]’ at 
/opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/alloc_traits.h:518:21,
    >     inlined from ‘constexpr void std::vector<_Tp, 
_Alloc>::_M_realloc_insert(iterator, _Args&& ...) [with _Args = {const long 
unsigned int&}; _Tp = long unsigned int; _Alloc = std::allocator<long unsigned 
int>]’ at /opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/vector.tcc:462:28,
    >     inlined from ‘constexpr void std::vector<_Tp, 
_Alloc>::push_back(const value_type&) [with _Tp = long unsigned int; _Alloc = 
std::allocator<long unsigned int>]’ at 
/opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/stl_vector.h:1287:21,
    >     inlined from ‘mdds::mtv::soa::multi_type_vector<Traits>::iterator 
mdds::mtv::soa::multi_type_vector<Traits>::set_cell_to_empty_block(size_type, 
size_type, const T&) [with T = rtl::OUString; Traits = 
mdds::multi_type_matrix<svl::{anonymous}::matrix_traits>::mtv_trait]’ at 
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/mdds/include/mdds/./multi_type_vector/soa/main_def.inl:2995:50,
    >     inlined from ‘mdds::mtv::soa::multi_type_vector<Traits>::iterator 
mdds::mtv::soa::multi_type_vector<Traits>::set_impl(size_type, size_type, const 
T&) [with T = rtl::OUString; Traits = 
mdds::multi_type_matrix<svl::{anonymous}::matrix_traits>::mtv_trait]’ at 
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/mdds/include/mdds/./multi_type_vector/soa/main_def.inl:1240:72,
    >     inlined from ‘mdds::mtv::soa::multi_type_vector<Traits>::iterator 
mdds::mtv::soa::multi_type_vector<Traits>::set(size_type, const T&) [with T = 
rtl::OUString; Traits = 
mdds::multi_type_matrix<svl::{anonymous}::matrix_traits>::mtv_trait]’ at 
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/mdds/include/mdds/./multi_type_vector/soa/main_def.inl:696:14,
    >     inlined from ‘void mdds::multi_type_matrix<Traits>::set(size_type, 
size_type, const string_type&) [with Traits = svl::{anonymous}::matrix_traits]’ 
at 
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/mdds/include/mdds/multi_type_matrix_def.inl:356:5,
    >     inlined from ‘void svl::GridPrinter::set(size_t, size_t, const 
rtl::OUString&)’ at 
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/svl/source/misc/gridprinter.cxx:68:25:
    > 
/opt/rh/gcc-toolset-12/root/usr/include/c++/12/bits/stl_construct.h:97:14: 
error: array subscript 0 is outside array bounds of ‘long unsigned int [0]’ 
[-Werror=array-bounds]
    >    97 |     { return ::new((void*)__location) 
_Tp(std::forward<_Args>(__args)...); }
    >       |              
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    (<https://ci.libreoffice.org/job/gerrit_linux_gcc_release/148699/>), etc.
    
    (The curly braces in sw/source/core/doc/doc.cxx had to be added to avoid an
    ensuing bogus
    
    > sw/source/core/doc/doc.cxx: In static member function ‘static void 
SwDoc::CalculatePagePairsForProspectPrinting(const SwRootFrame&, SwRenderData&, 
const SwPrintUIOptions&, sal_Int32)’:
    > sw/source/core/doc/doc.cxx:1000:5: error: ‘else’ without a previous ‘if’
    >  1000 |     else
    >       |     ^~~~
    
    )
    
    Change-Id: I902f6d74d897b9bf281dc9c821aff30e7e72582a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155215
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index fb9bf946fa47..8c3b3d4dd8a8 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -579,7 +579,14 @@ void ScMatrixImpl::PutEmptyPath(SCSIZE nC, SCSIZE nR)
     if (ValidColRow( nC, nR))
     {
         maMat.set_empty(nR, nC);
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 12 && __cplusplus == 
202002L
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
         maMatFlag.set(nR, nC, SC_MATFLAG_EMPTYPATH);
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 12 && __cplusplus == 
202002L
+#pragma GCC diagnostic pop
+#endif
     }
     else
     {
diff --git a/svl/source/misc/gridprinter.cxx b/svl/source/misc/gridprinter.cxx
index ef83a3b217ba..bdb9586e406b 100644
--- a/svl/source/misc/gridprinter.cxx
+++ b/svl/source/misc/gridprinter.cxx
@@ -68,7 +68,14 @@ GridPrinter::~GridPrinter()
 
 void GridPrinter::set( size_t nRow, size_t nCol, const OUString& rStr )
 {
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 12 && __cplusplus == 
202002L
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
     mpImpl->maMatrix.set(nRow, nCol, rStr);
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 12 && __cplusplus == 
202002L
+#pragma GCC diagnostic pop
+#endif
 }
 
 void GridPrinter::print( const char* pHeader ) const
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 07f54882fbdd..ec73c47f64c5 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -982,7 +982,17 @@ void SwDoc::CalculatePagePairsForProspectPrinting(
 
     // just one page is special ...
     if ( 1 == aVec.size() )
+    {
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 12 && __cplusplus == 
202002L
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
         aVec.insert( aVec.begin() + 1, nullptr ); // insert a second empty page
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 12 && __cplusplus == 
202002L
+#pragma GCC diagnostic pop
+#endif
+    }
     else
     {
         // now extend the number of pages to fit a multiple of 4

Reply via email to