Skip to content

Fix remaining [-Wmismatched-new-delete] gcc11 warnings

In the current gcc11 builds we suffer from spurious [-Wmismatched-new-delete] warning in the simple leakcheck.h depending on compiler decision on inlining.

One good description can be found here [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100861#c1]

!45516 (merged) by @ssnyder fixed that for 9 packages

Unfortunatelly we have 3 more that seem to be "more stuborn" As an example we still get

In function 'void operator delete(void*, size_t)',
    inlined from 'void __gnu_cxx::new_allocator<_Tp>::deallocate(_Tp*, __gnu_cxx::new_allocator<_Tp>::size_type) [with _Tp = std::_Rb_tree_node<std::pair<const ElementLink<Rec::TrackParticleContainer>, ElementLinkVector<Rec::TrackParticleContainer> > >]' at /cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos7/include/c++/11.1.0/ext/new_allocator.h:139:19,
    inlined from 'static void std::allocator_traits<std::allocator<_CharT> >::deallocate(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, std::allocator_traits<std::allocator<_CharT> >::pointer, std::allocator_traits<std::allocator<_CharT> >::size_type) [with _Tp = std::_Rb_tree_node<std::pair<const ElementLink<Rec::TrackParticleContainer>, ElementLinkVector<Rec::TrackParticleContainer> > >]' at /cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos7/include/c++/11.1.0/bits/alloc_traits.h:492:23,
  .....
    inlined from 'bool AssociationMap<OBJCONT, ASSCONT>::addToStore(const object_link&, const asso_link&) [with OBJCONT = Rec::TrackParticleContainer; ASSCONT = Rec::TrackParticleContainer]' at /build/atnight/localbuilds/nightlies/master--dev4LCG/athena/Control/AthLinks/AthLinks/AssociationMap.icc:273:1:
/build/atnight/localbuilds/nightlies/master--dev4LCG/athena/AtlasTest/TestTools/TestTools/leakcheck.h:74:7: warning: 'void free(void*)' called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
   74 |   free(ptr);
      |   ~~~~^~~~~
In file included from /cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos7/include/c++/11.1.0/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                 from /cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos7/include/c++/11.1.0/bits/allocator.h:46,
....
/cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos7/include/c++/11.1.0/ext/new_allocator.h: In function 'bool AssociationMap<OBJCONT, ASSCONT>::addToStore(const object_link&, const asso_link&) [with OBJCONT = Rec::TrackParticleContainer; ASSCONT = Rec::TrackParticleContainer]':
/cvmfs/sft.cern.ch/lcg/releases/gcc/11.1.0-e80bf/x86_64-centos7/include/c++/11.1.0/ext/new_allocator.h:121:48: note: returned from 'void* operator new(std::size_t)'
  121 |         return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));

So here trying to convince the compiler to not inline things. I checked that the warnings are gone with gcc11 and also that the code compiles with gcc8 and clang10 and that the test will still work.

Mentioning @ssnyder explicitly as he should prb take a look in any case for this one.

Merge request reports

Loading