connectivity/source/drivers/postgresql/pq_connection.cxx |    8 ++++++++
 1 file changed, 8 insertions(+)

New commits:
commit 3f5811a4649b9e43e610afd3ff57c14bd57589d0
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Wed Apr 10 21:31:36 2024 +0200
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Thu Apr 11 08:18:31 2024 +0200

    Silence strange -Warray-bounds with recent GCC 14
    
    ...seen at least with some (--enable-dbgutil --enable-optimized etc.)
    configuration and a recent GCC 14 trunk,
    
    > In file included from ~/gcc/inst/include/c++/14.0.1/vector:62,
    >                  from 
connectivity/source/drivers/postgresql/pq_connection.cxx:38:
    > In static member function ‘static constexpr _Up* 
std::__copy_move<_IsMove, true, 
std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = long 
unsigned int; _Up = long unsigned int; bool _IsMove = false]’,
    >     inlined from ‘constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with 
bool _IsMove = false; _II = long unsigned int*; _OI = long unsigned int*]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:521:30,
    >     inlined from ‘constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with 
bool _IsMove = false; _II = long unsigned int*; _OI = long unsigned int*]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:548:42,
    >     inlined from ‘constexpr _OI std::__copy_move_a(_II, _II, _OI) [with 
bool _IsMove = false; _II = long unsigned int*; _OI = long unsigned int*]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:555:31,
    >     inlined from ‘constexpr _OI std::copy(_II, _II, _OI) [with _II = long 
unsigned int*; _OI = long unsigned int*]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:651:7,
    >     inlined from ‘constexpr std::__cxx1998::vector<bool, 
_Alloc>::iterator std::__cxx1998::vector<bool, 
_Alloc>::_M_copy_aligned(const_iterator, const_iterator, iterator) [with _Alloc 
= std::allocator<bool>]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_bvector.h:1342:28,
    >     inlined from ‘constexpr void std::__cxx1998::vector<bool, 
_Alloc>::_M_reallocate(size_type) [with _Alloc = std::allocator<bool>]’ at 
~/gcc/inst/include/c++/14.0.1/bits/vector.tcc:1054:40,
    >     inlined from ‘constexpr void std::__cxx1998::vector<bool, 
_Alloc>::reserve(size_type) [with _Alloc = std::allocator<bool>]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_bvector.h:1130:17,
    >     inlined from ‘constexpr void std::__debug::vector<_Tp, 
_Allocator>::reserve(size_type) [with _Tp = bool; _Allocator = 
std::allocator<bool>]’ at ~/gcc/inst/include/c++/14.0.1/debug/vector:495:16,
    >     inlined from 
‘pq_sdbc_driver::{anonymous}::cstr_vector::cstr_vector()’ at 
connectivity/source/drivers/postgresql/pq_connection.cxx:338:58:
    > ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:452:30: error: ‘void* 
__builtin_memmove(void*, const void*, long unsigned int)’ forming offset 8 is 
out of the bounds [0, 8] [-Werror=array-bounds=]
    >   452 |             __builtin_memmove(__result, __first, sizeof(_Tp) * 
_Num);
    >       |             
~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    and
    
    > In file included from ~/gcc/inst/include/c++/14.0.1/vector:62,
    >                  from 
connectivity/source/drivers/postgresql/pq_connection.cxx:38:
    > In static member function ‘static constexpr _Up* 
std::__copy_move<_IsMove, true, 
std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = long 
unsigned int; _Up = long unsigned int; bool _IsMove = false]’,
    >     inlined from ‘constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with 
bool _IsMove = false; _II = long unsigned int*; _OI = long unsigned int*]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:521:30,
    >     inlined from ‘constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with 
bool _IsMove = false; _II = long unsigned int*; _OI = long unsigned int*]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:548:42,
    >     inlined from ‘constexpr _OI std::__copy_move_a(_II, _II, _OI) [with 
bool _IsMove = false; _II = long unsigned int*; _OI = long unsigned int*]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:555:31,
    >     inlined from ‘constexpr _OI std::copy(_II, _II, _OI) [with _II = long 
unsigned int*; _OI = long unsigned int*]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:651:7,
    >     inlined from ‘constexpr std::__cxx1998::vector<bool, 
_Alloc>::iterator std::__cxx1998::vector<bool, 
_Alloc>::_M_copy_aligned(const_iterator, const_iterator, iterator) [with _Alloc 
= std::allocator<bool>]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_bvector.h:1342:28,
    >     inlined from ‘constexpr void std::__cxx1998::vector<bool, 
_Alloc>::_M_reallocate(size_type) [with _Alloc = std::allocator<bool>]’ at 
~/gcc/inst/include/c++/14.0.1/bits/vector.tcc:1054:40,
    >     inlined from ‘constexpr void std::__cxx1998::vector<bool, 
_Alloc>::reserve(size_type) [with _Alloc = std::allocator<bool>]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_bvector.h:1130:17,
    >     inlined from ‘constexpr void std::__debug::vector<_Tp, 
_Allocator>::reserve(size_type) [with _Tp = bool; _Allocator = 
std::allocator<bool>]’ at ~/gcc/inst/include/c++/14.0.1/debug/vector:495:16,
    >     inlined from 
‘pq_sdbc_driver::{anonymous}::cstr_vector::cstr_vector()’ at 
connectivity/source/drivers/postgresql/pq_connection.cxx:338:58:
    > ~/gcc/inst/include/c++/14.0.1/bits/stl_algobase.h:452:30: error: ‘void* 
__builtin_memmove(void*, const void*, long unsigned int)’ writing between 9 and 
9223372036854775807 bytes into a region of size 8 overflows the destination 
[-Werror=stringop-overflow=]
    >   452 |             __builtin_memmove(__result, __first, sizeof(_Tp) * 
_Num);
    >       |             
~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > In file included from 
~/gcc/inst/include/c++/14.0.1/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
    >                  from ~/gcc/inst/include/c++/14.0.1/bits/allocator.h:46,
    >                  from ~/gcc/inst/include/c++/14.0.1/vector:63:
    > In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type, 
const void*) [with _Tp = long unsigned int]’,
    >     inlined from ‘constexpr _Tp* std::allocator< <template-parameter-1-1> 
>::allocate(std::size_t) [with _Tp = long unsigned int]’ at 
~/gcc/inst/include/c++/14.0.1/bits/allocator.h:196:40,
    >     inlined from ‘static constexpr _Tp* 
std::allocator_traits<std::allocator<_Up> >::allocate(allocator_type&, 
size_type) [with _Tp = long unsigned int]’ at 
~/gcc/inst/include/c++/14.0.1/bits/alloc_traits.h:478:28,
    >     inlined from ‘constexpr 
std::__cxx1998::_Bvector_base<_Alloc>::_Bit_pointer 
std::__cxx1998::_Bvector_base<_Alloc>::_M_allocate(std::size_t) [with _Alloc = 
std::allocator<bool>]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_bvector.h:679:48,
    >     inlined from ‘constexpr void std::__cxx1998::vector<bool, 
_Alloc>::_M_reallocate(size_type) [with _Alloc = std::allocator<bool>]’ at 
~/gcc/inst/include/c++/14.0.1/bits/vector.tcc:1052:43,
    >     inlined from ‘constexpr void std::__cxx1998::vector<bool, 
_Alloc>::reserve(size_type) [with _Alloc = std::allocator<bool>]’ at 
~/gcc/inst/include/c++/14.0.1/bits/stl_bvector.h:1130:17,
    >     inlined from ‘constexpr void std::__debug::vector<_Tp, 
_Allocator>::reserve(size_type) [with _Tp = bool; _Allocator = 
std::allocator<bool>]’ at ~/gcc/inst/include/c++/14.0.1/debug/vector:495:16,
    >     inlined from 
‘pq_sdbc_driver::{anonymous}::cstr_vector::cstr_vector()’ at 
connectivity/source/drivers/postgresql/pq_connection.cxx:338:58:
    > ~/gcc/inst/include/c++/14.0.1/bits/new_allocator.h:151:55: note: 
destination object of size 8 allocated by ‘operator new’
    >   151 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * 
sizeof(_Tp)));
    >       |                                                       ^
    
    Change-Id: I6ef1be6428363ff37d591207df379cc18ebea933
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165959
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx 
b/connectivity/source/drivers/postgresql/pq_connection.cxx
index 422d97f76e22..091479f87f95 100644
--- a/connectivity/source/drivers/postgresql/pq_connection.cxx
+++ b/connectivity/source/drivers/postgresql/pq_connection.cxx
@@ -331,7 +331,15 @@ class cstr_vector
     std::vector<char*> values;
     std::vector<bool>  acquired;
 public:
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 14
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
     cstr_vector ()  { values.reserve(8); acquired.reserve(8); }
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 14
+#pragma GCC diagnostic pop
+#endif
     ~cstr_vector ()
     {
         OSL_ENSURE(values.size() == acquired.size(), "pq_connection: 
cstr_vector values and acquired size mismatch");

Reply via email to