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

Dumper fails badly for std::string with custom allocator

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • Qt Creator 4.9.0-beta2
    • Qt Creator 4.9.0-beta2
    • Debugger
    • None
    • 41da97fb2cfb88baa7872d370e1e9665c85432d2

    Description

      If you define a string with a custom allocator, the dumper shows garbage instead of the string.

      On some occasions (could not figure out an exact example), the basic_string member is expandable, and if you expand it, the debugger hangs forever (must be aborted twice).

      #include <string>
      
      namespace ns {
      
      template<class T>
      struct alloc
      {
      public:
          typedef size_t size_type;
          typedef T* pointer;
          typedef const T* const_pointer;
          typedef T value_type;
          typedef T& reference;
          typedef const T& const_reference;
          typedef ptrdiff_t difference_type;
      
          inline bool operator==(const alloc<T>&) const { return true; }
          inline bool operator!=(const alloc<T>&) const { return false; }
      
          pointer allocate(size_t n) { return (pointer)allocator.allocate(n*sizeof(T)); }
          void deallocate(pointer p, size_t n) { allocator.deallocate(p, n); }
          std::allocator<T> allocator;
      };
      
      using allocat = alloc<char>;
      
      class string : public std::basic_string<char, std::char_traits<char>, allocat>
      {
          using base = std::basic_string<char, std::char_traits<char>, allocat>;
          using base::basic_string;
      };
      }
      
      int main()
      {
          std::string str1("test");
          ns::string str2("test");
          return 0; // Break here
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            hjk hjk
            orgads Orgad Shaneh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes