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

reinterpret_cast<>(nullptr) in qhashfunctions.h

XMLWordPrintable

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

      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.

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

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes