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

moc: Cannot handle "broken" raw-string

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 5.15.2
    • Build tools: moc
    • None

      We had a little mistake in our test code and found that moc cannot handle \n or \" in raw-strings.

      #include <QtCore/QObject>
      
      class Dummy : public QObject
      {
              Q_OBJECT
      
      public:
              Dummy()
              {
                      const QByteArray data(R"({
                                                                               "    \"example\": true\n"
                                                                               "}\n");
                                                                               })");
              }
      };
      
      int main()
      {
              Dummy d;
              return 0;
      }
      

      The compiler will build it and tries to link it. But it fails with "error: undefined reference to 'vtable for XYZ" because moc cannot handle that and throws a warning instead an error.

      $ moc test.cpp
      test.cpp:0: Note: No relevant classes found. No output generated.
      

      Moc should handle that or fail with a better warning message.

        For Gerrit Dashboard: QTBUG-89363
        # Subject Branch Project Status CR V

            fabiankosmale Fabian Kosmale
            misery André Klitzing
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There is 1 open Gerrit change