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

reinterpret_cast<>(nullptr) in qhashfunctions.h

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.12.6
    • 5.13.1
    • Core: Other
    • None
    • Windows
    • 31f07f3114218de758cc8c5b0f5b0d4e83669a5c (qt/qtbase/5.12)

    Description

      In qhashfunctions.h the code reads as

      Q_DECL_CONST_FUNCTION inline uint qHash(std::nullptr_t, uint seed = 0) Q_DECL_NOTHROW
      {
          return qHash(reinterpret_cast<quintptr>(nullptr), seed);
      }
      

      but reinterpret_cast<quintptr> cannot be used to cast from a nullptr. It probably should be changed into something like

      Q_DECL_CONST_FUNCTION inline uint qHash(std::nullptr_t, uint seed = 0) Q_DECL_NOTHROW 
      {
         void* ptr = nullptr;
         return qHash(reinterpret_cast<quintptr>(ptr), seed);
      }
      

      The current implementation results in a compiler error with the v140 Toolchain of Visual Studio.

      Attachments

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

        Activity

          People

            vhilshei Volker Hilsheimer
            robing Robin Gutöhrlein
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes