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

qHash woes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.1.0
    • None
    • gcc 10.2.1 - here Linux/X11
    • All

    Description

      Since Qt 6 I'm running into this compiler warning ( here gcc 10.2.1 ) with a qHash implementation for a custom type:

      warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second.
      

      The corresponding code looks like this:

      class AxisId
      {
        public:
          AxisId( int position, int index = 0 );
          ...
      };
      
      inline uint qHash( const AxisId& axisId, uint seed = 0 ) noexcept
      {
          ...
      }
      

      Now when calling qHash for an int it seems to be unclear for gcc wether it should call qHash( int, ... ) or qHash( AxisId, ... ). I didn't check what gcc is actually doing, but from the warning my guess would be, that it takes the wrong one for AxisId.

      Guess this is a general problem of the implementation in Qt6. It is not possible to define a qHash operation for a type that has a constructor from a type where a qHash implementation exists.

      The complete code can be found here: https://sourceforge.net/p/qwt/code/HEAD/tree/branches/qwt-6.1-multiaxes/src/qwt_axis_id.h

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            uwe Uwe Rathmann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes