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

qstring.h, qstringbuilder.h: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 6.0
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      iOS/tvOS/watchOS, macOS

      Description

      There are warnings in qstring.h / qstringbuilder.h about qsizetype to int conversion when compiling with -Wshorten-64-to-32 on iOS, macOS:

      agent:2020/08/24 09:30:03 build.go:302: In file included from /Users/qt/work/qt/qtbase/src/corelib/global/qendian.h:44:
      agent:2020/08/24 09:30:03 build.go:302: In file included from /Users/qt/work/qt/qtbase/build/host/include/QtCore/qfloat16.h:1:
      agent:2020/08/24 09:30:03 build.go:302: In file included from /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/global/qfloat16.h:45:
      agent:2020/08/24 09:30:03 build.go:302: In file included from /Users/qt/work/qt/qtbase/build/host/include/QtCore/qmetatype.h:1:
      agent:2020/08/24 09:30:03 build.go:302: In file included from /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/kernel/qmetatype.h:48:
      agent:2020/08/24 09:30:03 build.go:302: In file included from /Users/qt/work/qt/qtbase/build/host/include/QtCore/qvarlengtharray.h:1:
      agent:2020/08/24 09:30:03 build.go:302: In file included from /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/tools/qvarlengtharray.h:47:
      agent:2020/08/24 09:30:03 build.go:302: In file included from /Users/qt/work/qt/qtbase/build/host/include/QtCore/qhashfunctions.h:1:
      agent:2020/08/24 09:30:03 build.go:302: In file included from /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/tools/qhashfunctions.h:44:
      agent:2020/08/24 09:30:03 build.go:302: In file included from /Users/qt/work/qt/qtbase/build/host/include/QtCore/qstring.h:1:
      agent:2020/08/24 09:30:03 build.go:302: /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/text/qstring.h:189:99: error: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int' [-Werror,-Wshorten-64-to-32]
      agent:2020/08/24 09:30:03 build.go:302:         return result == QContainerImplHelper::Null ? QLatin1String() : QLatin1String(m_data + p, l);
      agent:2020/08/24 09:30:03 build.go:302:                                                                         ~~~~~~~~~~~~~             ^
      agent:2020/08/24 09:30:03 build.go:302: /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/text/qstring.h:1103:16: error: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int' [-Werror,-Wshorten-64-to-32]
      agent:2020/08/24 09:30:03 build.go:302:         return QString::toUcs4_helper(reinterpret_cast<const ushort *>(data()), int(size()),
      agent:2020/08/24 09:30:03 build.go:302:         ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      agent:2020/08/24 09:30:03 build.go:302: /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/text/qstring.h:1337:15: error: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int' [-Werror,-Wshorten-64-to-32]
      agent:2020/08/24 09:30:03 build.go:302:     int len = toUcs4_helper(reinterpret_cast<const ushort *>(constData()), length(),
      agent:2020/08/24 09:30:03 build.go:302:         ~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      agent:2020/08/24 09:30:03 build.go:302: /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/text/qstring.h:1533:65: error: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int' [-Werror,-Wshorten-64-to-32]
      agent:2020/08/24 09:30:03 build.go:302: { m_string = aString; m_position = 0; m_size = aString?aString->size():0; return *this; }
      agent:2020/08/24 09:30:03 build.go:302:                                              ~         ~~~~~~~~~^~~~~~
      agent:2020/08/24 09:30:03 build.go:302: /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/text/qstring.h:1539:64: error: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int' [-Werror,-Wshorten-64-to-32]
      agent:2020/08/24 09:30:03 build.go:302:     :m_string(aString), m_position(0), m_size(aString?aString->size() : 0){}
      agent:2020/08/24 09:30:03 build.go:302:                                              ~        ~~~~~~~~~^~~~~~
      [...]
      agent:2020/08/24 09:30:03 build.go:302: /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/text/qstringbuilder.h:259:50: error: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int' [-Werror,-Wshorten-64-to-32]
      agent:2020/08/24 09:30:03 build.go:302:     static int size(const QString &a) { return a.size(); }
      agent:2020/08/24 09:30:03 build.go:302:                                         ~~~~~~ ~~^~~~~~
      agent:2020/08/24 09:30:03 build.go:302: /Users/qt/work/qt/qtbase/build/host/include/QtCore/../../../../src/corelib/text/qstringbuilder.h:262:25: error: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'const int' [-Werror,-Wshorten-64-to-32]
      agent:2020/08/24 09:30:03 build.go:302:         const int n = a.size();
      

      Should these conversions be made explicit, or do should we remove the check from headersclean?

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              thiago Thiago Macieira
              Reporter:
              kkohne Kai Köhne
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes