From 10e452793ccf96d4c8f3ae372da7b5bc054d900a Mon Sep 17 00:00:00 2001
From: scott snyder <snyder@bnl.gov>
Date: Thu, 4 Oct 2018 11:39:16 +0200
Subject: [PATCH] CaloEvent: Add workaround fror ROOT-9709.

With root 6.14.04 and gcc8, cling is observed to sometimes crash when
handling a STL tree container.  Reported as ROOT-9709.
Work around by hiding this data member from cling.
---
 .../CaloEvent/CaloClusterMomentStore.h        | 37 +++++++++++++------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/Calorimeter/CaloEvent/CaloEvent/CaloClusterMomentStore.h b/Calorimeter/CaloEvent/CaloEvent/CaloClusterMomentStore.h
index 4bd4d604c8d..1a665a806a1 100644
--- a/Calorimeter/CaloEvent/CaloEvent/CaloClusterMomentStore.h
+++ b/Calorimeter/CaloEvent/CaloEvent/CaloClusterMomentStore.h
@@ -40,27 +40,38 @@ class CaloClusterMomentStore
   /*! \brief List of moment types */
   typedef std::vector<moment_type>                  moment_type_list;
 
+  // Work around ROOT-9709.  Hide m_actual from cling --- but that means
+  // that we also need to ensure that the inline functions defined here
+  // are actually emitted out-of-line.
+#ifdef __CLING__
+#  define ATH_CLING_BODY(BODY) ;
+#else
+#  define ATH_CLING_BODY(BODY) __attribute__((used)) BODY
+#endif
+
   /*! \brief Internally used iterator */
   class CaloClusterMomentIterator
     {
     public:
       /*! \brief Default constructor */
-      CaloClusterMomentIterator() { };
+      CaloClusterMomentIterator() ATH_CLING_BODY( { } )
       /*! \brief Useful constructor */
       CaloClusterMomentIterator(moment_store_const_iter iStore)
-	: m_actual(iStore) { };
+	ATH_CLING_BODY (: m_actual(iStore) { } )
       /*! \brief Destructor */
-      ~CaloClusterMomentIterator() { };
+      ~CaloClusterMomentIterator() ATH_CLING_BODY( { } )
 
       /*! \brief Iterator advance method */
-      CaloClusterMomentIterator next()          { m_actual++; return *this; }
+      CaloClusterMomentIterator next()
+        ATH_CLING_BODY( { m_actual++; return *this; } )
       /*! \brief Iterator post advance operator */
       CaloClusterMomentIterator operator++()    { return this->next(); }
       /*! \brief Iterator prior advance operator */
       CaloClusterMomentIterator operator++(int) { return this->next(); }
       
       /*! \brief Iterator reverse method */
-      CaloClusterMomentIterator prev()          { m_actual--; return *this; }
+      CaloClusterMomentIterator prev()
+        ATH_CLING_BODY( { m_actual--; return *this; } )
       /*! \brief Iterator post reverse operator */
       CaloClusterMomentIterator operator--()    { return this->prev(); }
       /*! \brief Iterator prior reverse operator */
@@ -72,7 +83,7 @@ class CaloClusterMomentStore
        *                     compared to 
        */
       bool operator==(const CaloClusterMomentIterator& anOtherIter) const
-	{ return m_actual == anOtherIter.m_actual; }
+        ATH_CLING_BODY( { return m_actual == anOtherIter.m_actual; } )
       /*! \brief Equality comparator
        *
        *  \overload
@@ -81,7 +92,7 @@ class CaloClusterMomentStore
        *                     compared to 
        */
       bool operator==(CaloClusterMomentIterator& anOtherIter)
-	{ return m_actual == anOtherIter.m_actual; } 
+        ATH_CLING_BODY( { return m_actual == anOtherIter.m_actual; } )
 
       /*! \brief Inequality comparator
        *
@@ -89,7 +100,7 @@ class CaloClusterMomentStore
        *                     compared to 
        */
       bool operator!=(const CaloClusterMomentIterator& anOtherIter) const
-	{ return m_actual != anOtherIter.m_actual; }
+        ATH_CLING_BODY( { return m_actual != anOtherIter.m_actual; } )
       /*! \brief Inequality comparator
        *
        *  \overload
@@ -98,22 +109,24 @@ class CaloClusterMomentStore
        *                     compared to 
        */
       bool operator!=(CaloClusterMomentIterator& anOtherIter)
-	{ return m_actual != anOtherIter.m_actual; }
+        ATH_CLING_BODY( { return m_actual != anOtherIter.m_actual; } )
 
       /*! \brief Data access operator */
       //      CaloClusterMoment& operator*() { return this->getMoment(); }
       const CaloClusterMoment& operator*() const { return this->getMoment(); }
       /*! \brief Data access method */
       //      CaloClusterMoment& getMoment() { return (*m_actual).second; }
-      const CaloClusterMoment& getMoment() const { return (*m_actual).second; }
+      const CaloClusterMoment& getMoment() const
+        ATH_CLING_BODY( { return (*m_actual).second; } )
       /*! \brief Key access method */
       moment_type getMomentType() const   
-	{ return (moment_type)(*m_actual).first; }
+        ATH_CLING_BODY( { return (moment_type)(*m_actual).first; } )
 
     private:
-
+#ifndef __CLING__
       /*! \brief Internal moment iterator */
       moment_store_const_iter m_actual;
+#endif
     };
 
   /*! \brief External moment iterator type */
-- 
GitLab