Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-23388

Pretty-printing of boost::shared_ptr broken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • Qt Creator 4.11.0
    • Debugger
    • Arch Linux
      kernel: 5.4.3-arch1-1
      g++ --version: g++ (GCC) 9.2.0
      gdb --version: GNU gdb (GDB) 8.3.1
      ldd --version: ldd (GNU libc) 2.30
      boost: 1.71.0-2
    • Linux/X11

    Description

      Pretty-printing fails ind QtCreator if std::map, boost::shared_ptr and boost::enable_shared_from_this are used in conjunction.

      Compile the code below in debug mode and set a break point at asm("nop"), run the program and see that all entries (*.second) of map are not accessible:

       

      testme.cpp:

      #include <map>
      #include <boost/shared_ptr.hpp>
      #include <boost/enable_shared_from_this.hpp>
      
      class T : public boost::enable_shared_from_this<T>
      {
      public:
          T() : y(987) {}    
          int x = 123;
          int y;
      };
      
      using TPtr = boost::shared_ptr<T>;
      using TMap = std::map<std::string, TPtr>;
      
      int main(int, char**)  {
          TMap map;
          for (int i = 0; i < 300; ++i) {
              boost::shared_ptr<T> t(new T);
              map[std::string("item_") + std::to_string(i)] = t;
          }
          asm("nop");
      }
      
      

       

      CMakeLists.txt:

       

      project(test_project)
      
      cmake_minimum_required(VERSION 3.14)
      
      set(CMAKE_CXX_STANDARD 11)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
      add_definitions("-O0")
      find_package(Boost)
      add_executable(testme
       testme
      )
      
      
      target_include_directories(testme
       PRIVATE ${Boost_INCLUDE_DIRS}
      )
       
      target_link_libraries(testme 
      
       ${Boost_LIBRARIES}
      )
      

       

      Attachments

        1. CMakeLists.txt
          0.3 kB
        2. image-2019-12-17-10-12-45-755.png
          image-2019-12-17-10-12-45-755.png
          14 kB
        3. testme.cpp
          0.5 kB

        Activity

          People

            hjk hjk
            sedenion Dominik Neudert-Schulz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: