Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-79398

[REG: 5.7 -> 5.8] QSharedPointer code doesn't compile anymore

    XMLWordPrintable

Details

    Description

      #include <qsharedpointer.h>
      
      struct F {
          virtual ~F(){}
      };
      struct T : F {
      protected:
          ~T(){}
      };
      
      int main(int argc, char *argv[])
      {
          QSharedPointer<F>(new T);
      }
      
      ../../../Qt/5.13.1/gcc_64/include/QtCore/qsharedpointer_impl.h: In instantiation of ‘void QtSharedPointer::CustomDeleter<T, QtSharedPointer::NormalDeleter>::execute() [with T = T]’:
      ../../../Qt/5.13.1/gcc_64/include/QtCore/qsharedpointer_impl.h:213:13:   required from ‘static void QtSharedPointer::ExternalRefCountWithCustomDeleter<T, Deleter>::deleter(QtSharedPointer::ExternalRefCountData*) [with T = T; Deleter = QtSharedPointer::NormalDeleter]’
      ../../../Qt/5.13.1/gcc_64/include/QtCore/qsharedpointer_impl.h:491:55:   required from ‘void QSharedPointer<T>::internalConstruct(X*, Deleter) [with X = T; Deleter = QtSharedPointer::NormalDeleter; T = F]’
      ../../../Qt/5.13.1/gcc_64/include/QtCore/qsharedpointer_impl.h:321:24:   required from ‘QSharedPointer<T>::QSharedPointer(X*) [with X = T; T = F]’
      ../untitled2/main.cpp:18:28:   required from here
      ../untitled2/main.cpp:13:5: error: ‘virtual T::~T()’ is protected
           ~T(){}
           ^
      In file included from ../../../Qt/5.13.1/gcc_64/include/QtCore/qsharedpointer.h:48:0,
                       from ../../../Qt/5.13.1/gcc_64/include/QtQml/qjsengine.h:46,
                       from ../../../Qt/5.13.1/gcc_64/include/QtQml/qqmlengine.h:46,
                       from ../../../Qt/5.13.1/gcc_64/include/QtQml/qqmlapplicationengine.h:43,
                       from ../../../Qt/5.13.1/gcc_64/include/QtQml/QQmlApplicationEngine:1,
                       from ../untitled2/main.cpp:2:
      ../../../Qt/5.13.1/gcc_64/include/QtCore/qsharedpointer_impl.h:195:26: error: within this context
               void execute() { delete ptr; }
                                ^
      

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            poikelin Joni Poikelin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes