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

QMetaEnum doesn't support negative enumerator values

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P3: Somewhat important
    • None
    • dev
    • Build tools: moc
    • None

    Description

      In tst_QMetaObject::checkScope():

      MyAnotherEnum3 is an enumerator with value "-1"; this test:
      QCOMPARE(me2.keyToValue("MyAnotherEnum3", &ok), -1);

      only passes due to integer overflow. The enumerators are stored as uint
      in the generated code:
      uint(MyNamespace::MyClass2::MyAnotherEnum3)

      uint(-1) is 4294967295; keyToValue() returns int(4294967295) which overflows and becomes -1 letting the test pass.

      I am not sure how this should be fixed; at least it should be documented in QMetaEnum API docs.

      Attachments

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

        Activity

          People

            fabiankosmale Fabian Kosmale
            ahmad.samir Ahmad Samir
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes