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

REG [5.15 -> 6.x] QByteArray::replace(0, size(), ptr, n) became ambiguous on 64-bit platforms

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P2: Important
    • None
    • 6.2.5, 6.3.1, 6.4.0 Beta2
    • None

    Description

      In Qt 5, the replace overloads

      replace(int, int, const char*, int);
      replace(const char*, int, const char*, int);
      

      were non-ambiguous when passing 0 as the first argument, because decltype(0) is int.

      In Qt 6, the ints were changed to qsizetype, so now

      replace(0, qsizetype{}, nullptr, qsizetype{});
      

      is ambiguous, because the int could equally convert to qsizetype as to const char*.

      This is particularly important, because QByteArray lacks std::string's assign(ptr, n) function which could re-use the allocated memory, unlike assigning a new QByteArray, which always allocates new memory. So we've been using

      ba.replace(0, ba.size(), data, len);
      

      in lieu of what in std::string would be

      str.assign(data, len);
      

      and run into this problem everywhere.

      Attachments

        Issue Links

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

          Activity

            People

              mmutz Marc Mutz
              mmutz Marc Mutz
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes