fix build
[LibreOffice.git] / external / mdds / gcc-12-silence-use-after-free.patch.1
blob3f8dd0afe0f3bc12f43d8d65d9e6442a6ffbb39f
1 Workaround for gcc-toolset-12 on almalinux8 on a release/optimized build:
2 [build CXX] sc/source/core/data/column2.cxx
3 In file included from /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/mdds/include/mdds/flat_segment_tree.hpp:37,
4                  from /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/sc/inc/columnspanset.hxx:16,
5                  from /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/sc/inc/column.hxx:25,
6                  from /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/sc/source/core/data/column2.cxx:20:
7 In function ‘void mdds::__st::intrusive_ptr_release(node<T>*) [with T = mdds::flat_segment_tree<int, bool>]’,
8     inlined from ‘boost::intrusive_ptr<T>::~intrusive_ptr() [with T = mdds::__st::node<mdds::flat_segment_tree<int, bool> >]’ at /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/boost/boost/smart_ptr/intrusive_ptr.hpp:100:44,
9     inlined from ‘std::pair<mdds::flat_segment_tree<Key, Value>::const_iterator, bool> mdds::flat_segment_tree<Key, Value>::insert_segment_impl(key_type, key_type, value_type, bool) [with Key = int; Value = bool]’ at /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/mdds/include/mdds/flat_segment_tree_def.inl:225:1:
10 /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/mdds/include/mdds/node.hpp:247:10: error: pointer used after ‘void operator delete(void*, std::size_t)’ [-Werror=use-after-free]
11   247 |     --p->refcount;
12       |       ~~~^~~~~~~~
13 In function ‘void mdds::__st::intrusive_ptr_release(node<T>*) [with T = mdds::flat_segment_tree<int, bool>]’,
14     inlined from ‘void mdds::__st::intrusive_ptr_release(node<T>*) [with T = mdds::flat_segment_tree<int, bool>]’ at /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/mdds/include/mdds/node.hpp:245:13,
15     inlined from ‘boost::intrusive_ptr<T>::~intrusive_ptr() [with T = mdds::__st::node<mdds::flat_segment_tree<int, bool> >]’ at /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/boost/boost/smart_ptr/intrusive_ptr.hpp:100:44,
16     inlined from ‘std::pair<mdds::flat_segment_tree<Key, Value>::const_iterator, bool> mdds::flat_segment_tree<Key, Value>::insert_segment_impl(key_type, key_type, value_type, bool) [with Key = int; Value = bool]’ at /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/mdds/include/mdds/flat_segment_tree_def.inl:224:93:
17 /home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_gcc_release_64/workdir/UnpackedTarball/mdds/include/mdds/node.hpp:249:9: note: call to ‘void operator delete(void*, std::size_t)’ here
18   249 |         delete p;
19       |         ^~~~~~~~
20 cc1plus: all warnings being treated as errors
22 diff -ur mdds.org/include/mdds/node.hpp mdds/include/mdds/node.hpp
23 --- mdds.org/include/mdds/node.hpp      2023-07-24 18:27:14.427139325 +0000
24 +++ mdds/include/mdds/node.hpp  2023-07-24 18:26:54.554461294 +0000
25 @@ -244,9 +244,15 @@
26  template<typename T>
27  inline void intrusive_ptr_release(node<T>* p)
28  {
29 -    --p->refcount;
30 -    if (!p->refcount)
31 +#if defined __GNUC__ && __GNUC__ == 12 && __GNUC_MINOR__ < 3 && !defined __clang__
32 +#pragma GCC diagnostic push
33 +#pragma GCC diagnostic ignored "-Wuse-after-free"
34 +#endif
35 +    if(--p->refcount == 0)
36          delete p;
37 +#if defined __GNUC__ && __GNUC__ == 12 && __GNUC_MINOR__ < 3 && !defined __clang__
38 +#pragma GCC diagnostic pop
39 +#endif
40  }
42  template<typename T>