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

qRgba has undefined behavior

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.6.0 RC
    • 5.5.1
    • Core: Other
    • None
    • 837b5d458970f3981859cb9dfa0cec5fcd6d0c4f

    Description

      The definition of qRgba is:

      inline Q_DECL_CONSTEXPR QRgb qRgba(int r, int g, int b, int a)// set RGBA value

      { return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }

      Shifting the alpha value has undefined behavior, it needs to be converted to an unsigned int first.

      This results in slow code with Visual C++, when VC++ is using SSE auto-vectorization.

      (qRgb does the right thing, it's using an unsigned constant of 0xffu as alpha value.)

      Attachments

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

        Activity

          People

            tni Tilo Nitzsche
            tni Tilo Nitzsche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes