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

QTimer::singleShot accepts and ignores pointer to nonstatic method

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.6.0 RC
    • 5.4.1
    • Core: Date/Time
    • None
    • I54b7d14124459e450c6a0a93a3033f21b57605d9

    Description

      I have the following code:

      #include <QCoreApplication>
      #include <QTimer>
      
      struct Test : public QObject
      {
          void foo() {}
      };
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          QTimer::singleShot(1000, &Test::foo);
      
          return a.exec();
      }
      

      It compiles with both VS2013 on Windows and clang 6.1 on OSX, selecting the overload of 'singleShot' that takes a functor. Now, 'foo' is non-static method, so there's no way to call it without object, and in this example, I don't even create any instance of 'Test'. I believe this should be a compile error, as opposed to silently having no effect.

      Attachments

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

        Activity

          People

            ogoffart Olivier Goffart (Woboq GmbH)
            vladimir.prus Vladimir Prus
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes