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

moc should use std::addressof for taking an address instead of operator&

    XMLWordPrintable

Details

    • 5b99f3a34fef527beb8767eb12657f81ee65b969 (qt/qtbase/dev)

    Description

      In case a parameter is of type that overrides operator&, it causes problems for moc generated code which would take the result of operator&() instead of the object address. Using std::addressof() in those cases should work better.

      For example:

      class F : public QObject {
       Q_OBJECT
      public:
       void* operator&() { return nullptr; }
      signals:
       void something(F&);
      };
      

      Results in this, where it causes _a[1] to be nullptr as it calls F::operator&():

      // SIGNAL 0
      void F::something(F & _t1)
      {
          void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
          QMetaObject::activate(this, &staticMetaObject, 0, _a);
      }
      

      Attachments

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

        Activity

          People

            nierob Nierob
            poikelin Joni Poikelin
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes