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

moc generated codes trigger `-Werror=unsafe-buffer-usage` warning/error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.7.2
    • Build tools: moc
    • None
    • Linux/X11

    Description

      MOC auto-generated codes don't play nice with Clang's `-Wunsafe-buffer-usage` / `-Werror=unsafe-buffer-usage`.

      this is the header:

      ```cpp
      #include <QWindow>

      class VulkanWindow : public QWindow
      {
      Q_OBJECT
      public:
      VulkanWindow(QWindow *parent = nullptr)
      : QWindow(parent)
      {}

      void closeEvent(QCloseEvent *event) override

      { emit windowClosed(); QWindow::closeEvent(event); }

      signals:
      void windowClosed();
      };
      ```

      This is the compile time error:

      In file included from project/build/Desktop_Qt_6_7_2-Debug/main_autogen/mocs_compilation.cpp:2:
      project/build/Desktop_Qt_6_7_2-Debug/main_autogen/UVLADIE3JM/moc_vulkanwindow.cpp:84:90: error: '_a' is an unsafe pointer used for buffer access [-Werror,-Wunsafe-buffer-usage]
      84 | void VulkanWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)

      ~~~~~~^
      project/build/Desktop_Qt_6_7_2-Debug/main_autogen/UVLADIE3JM/moc_vulkanwindow.cpp:97:85: note: used in buffer access here
      97
      if (_t _q_method = &VulkanWindow::windowClosed; *reinterpret_cast<_t *>(_a[1]) == _q_method) {
      ^~
      1 error generated.

      (yeah i can't figure out how to properly format. why is markdown not supported?)

      Attachments

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

        Activity

          People

            fabiankosmale Fabian Kosmale
            jclink Jessia Clinkscale
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes