From 0c541ffa409924e92b646988e6c2cde2cf60df76 Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Fri, 27 Oct 2023 09:54:22 -0400 Subject: [PATCH] Work around issue with clang implicit instantiation in C++ mode. GaudiHandleBase has a virtual destructor which is declared with `=default'. However. in C++20 mode, clang will then try to instiantiate all the virtual functions for classes derived from this whenever the declarations for those classes are seen. The upshot is that then using Gaudi handles with forward-declared classes doesn't work (even if the handle is only declared in the header but not used in any way). It turns out that we can avoid this behavior by changing the declaration of the base class destructor to say `{}' instead of `=default'. (This is perhaps a clang bug, but the standard is not very clear on exactly when virtual members of the templated class are required to be or not to be implicitly instantiated.) See also ATLINFR-5113. --- GaudiKernel/include/GaudiKernel/GaudiHandle.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/GaudiKernel/include/GaudiKernel/GaudiHandle.h b/GaudiKernel/include/GaudiKernel/GaudiHandle.h index 5dc964bedd..3acec1ce2a 100644 --- a/GaudiKernel/include/GaudiKernel/GaudiHandle.h +++ b/GaudiKernel/include/GaudiKernel/GaudiHandle.h @@ -1,5 +1,5 @@ /***********************************************************************************\ -* (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations * +* (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations * * * * This software is distributed under the terms of the Apache version 2 licence, * * copied verbatim in the file "LICENSE". * @@ -47,7 +47,10 @@ protected: public: /** virtual destructor so that derived class destructor is called. */ - virtual ~GaudiHandleInfo() = default; + // Don't use =default here. Otherwise, in c++20 mode, clang will + // instantiate the handle virtual functions early, breaking the case + // where handles are used with a forward-declared class. + virtual ~GaudiHandleInfo() {} // // Public member functions // -- GitLab