Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-8422

segmentation fault when instantiating a templated class with "disabled" methods

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 6.08/00
    • Fix Version/s: 6.10/00, 6.08/02
    • Component/s: None
    • Labels:
      None
    • Environment:

      LHCb nightlies

      Description

      I have a piece of code that uses SFINAE/enable_if constructs to implement a kind of smart_ref.
      A reduced version of my code looks like (attached):

      #include <map>
       
      template<class STORAGE>
      struct TestSFINAE {
        template<class T=STORAGE>
        inline decltype( std::declval<T>().find( typename T::key_type{} ) ) find( const typename T::key_type& key ) {
          return _data.find(key);
        }
        STORAGE _data;
      };
       
      using MapRef = TestSFINAE<std::map<int,int>>;
      using BoolRef = TestSFINAE<bool>;

      With ROOT 6-08-patches I'm getting a segfault with this piece of Python:

      $ python
      Python 2.7.10 (default, Jun 17 2016, 00:44:54) 
      [GCC 4.9.3] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import cppyy
      >>> cppyy.gbl.gInterpreter.Declare('#include "test.h"')
      True
      >>> cppyy.gbl.MapRef
      <class 'cppyy.TestSFINAE<map<int,int> >'>
      >>> cppyy.gbl.BoolRef
      error: type 'bool' cannot be used prior to '::' because it has no members
      note: in instantiation of member function 'TestSFINAE<bool>::find' requested here
       
       *** Break *** segmentation violation

      while it works with ROOT 6-06-patches:

      $ python
      Python 2.7.10 (default, Jun 17 2016, 00:44:54) 
      [GCC 4.9.3] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import cppyy
      >>> cppyy.gbl.gInterpreter.Declare('#include "test.h"')
      True
      >>> cppyy.gbl.MapRef
      <class 'cppyy.TestSFINAE<map<int,int> >'>
      >>> cppyy.gbl.BoolRef
      <class 'cppyy.TestSFINAE<bool>'>
      >>> 

      I get a segfault in cling too, when I use tab completion:

      • ROOT 6-06-patches (correct)

        $ root
           -------------------------------------------------------------------------
          | Welcome to ROOT 6.06/09                             http://root.cern.ch |
          |                                            (c) 1995-2016, The ROOT Team |
          | Built for linuxx8664gcc                                                 |
          | From heads/v6-06-00-patches@v6-06-08-13-g7c45c0d, Oct 24 2016, 02:04:00 |
          | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'              |
           -------------------------------------------------------------------------
         
        root [0] #include "test.h"
        root [1] MapRef a;
        root [2] BoolRef b;
        root [3] b.<TAB>
         
        TestSFINAE<bool>
        _data
        operator=
        ~TestSFINAE<bool>
        root [3] .q

      • ROOT 6-08-patches (segfault)

        $ root
           ------------------------------------------------------------------------------
          | Welcome to ROOT 6.07/09                                  http://root.cern.ch |
          |                                                 (c) 1995-2016, The ROOT Team |
          | Built for linuxx8664gcc                                                      |
          | From heads/v6-08-00-patches@v6-08-00-rc1-101-gdebad99, Oct 24 2016, 18:51:00 |
          | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'                   |
           ------------------------------------------------------------------------------
         
        root [0] #include "test.h"
        root [1] MapRef a;
        root [2] BoolRef b;
        root [3] b
        (BoolRef &) @0x7fe321c21050
        root [4] b.error: type 'bool' cannot be used prior to '::' because it has no members
        note: in instantiation of member function 'TestSFINAE<bool>::find' requested here
         
         *** Break *** segmentation violation
        	Root > b.Error in <TTabCom::DetermineClass>: variable "b" not defined?
         
        problem determining class of "b"
         
        variable "b." not defined.
        Root > .q

      I didn't spot it earlier because is some new code in Gaudi that I developed against ROOT 6.06.

        Attachments

          Activity

            People

            • Assignee:
              axel Axel Naumann
              Reporter:
              clemenci Marco Clemencic
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: