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

Moc fails to handle C++ template parameter containing '<' or '>'

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.1.0
    • 4.8.0, 4.8.1, 4.8.2, 4.8.3, 4.8.4, 5.0.1, 5.0.2, 5.1.0 Beta 1
    • Build tools: moc
    • None
    • It is the logic bug, any platform should be able to reproduce this issue.

    Description

      The following code snippet just doesn't work:

      [hidden]$ cat xx.h
      template <bool b> struct X {};
      struct Y : X<-1<0> {};

      class X : public QObject {
      Q_OBJECT
      };
      [hidden]$ moc xx.h -o xx.cpp
      xx.h:0: Note: No relevant classes found. No output generated.

      I tried both the moc in qt4 and qt5, none of them can handle it correctly.

      This bug basically prevents building Qt using clang+libcxx because libcxx's <type_traits> header uses such techniques for is_signed template (it uses (T)-1<(T)0 to figure out if a type is signed or not). It makes the moc segment fault.

      Please fix this issue! Any code that has '<' in the template parameter will break, not only limited to the clang header.

      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)
            icando Kan Li
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes