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

Unrechable code in MetaTypeQFutureHelper

    XMLWordPrintable

Details

    • Windows
    • 1
    • ff6bf61b1 (dev), 7a7c7322f (6.9), 52b46a7c4 (6.9.0), 684be0cff (6.8), bb906bfe1 (tqtc/lts-6.5)
    • Foundation Sprint 126

    Description

      Code fails to compile with treating warnings as errors feature enabled.

      Code example (also attached project):

      class MyClass : public QObject
      {
          Q_OBJECT
      public:
          Q_INVOKABLE QFuture<void> something(const QString &path);
      }; 

       

      The problem occurs in the next code in `qfuture.h` file:

      template<typename T>
      struct MetaTypeQFutureHelper<QFuture<T>>
      {
          static bool registerConverter() {
              if constexpr (std::is_same_v<T, void>)
                  return false;        
              return QMetaType::registerConverter<QFuture<T>, QFuture<void>>(
                      [](const QFuture<T> &future) { return QFuture<void>(future); });
          }
      }; 

       

      Since `something` return void future, everything after first return become to unreachable code.

      Attachments

        1. untitled.zip
          3 kB
          Alexander Kaminsky
        For Gerrit Dashboard: QTBUG-133406
        # Subject Branch Project Status CR V

        Activity

          People

            ivan.solovev Ivan Solovev
            alexander.k Alexander Kaminsky
            Vladimir Minenko Vladimir Minenko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: