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

qurlrecode memcpy triggering a fatal warning

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P0: Blocker
    • 6.3.0 Alpha
    • 6.3.0 Alpha
    • Core: URL Handling
    • None
    • Linux, gcc 11.1
    • 80256b3683ca95907e71a7c127c74b865b1f0fe7 (qt/qtbase/dev)

    Description

      [34/14293] Building CXX object qtbase/src/tools/bootstrap/CMakeFiles/Bootstrap.dir/__/__/corelib/io/qurlrecode.cpp.o
      /home/rutledge/dev/qt6/qtbase/src/corelib/io/qurlrecode.cpp: In function ‘qsizetype decode(QString&, QStringView)’:
      /home/rutledge/dev/qt6/qtbase/src/corelib/io/qurlrecode.cpp:594:11: warning: ‘void* memcpy(void*, const void*, size_t)’ copying an object of non-trivial type ‘class QChar’ from an array of ‘const char16_t’ [-Wclass-memaccess]
        594 |     memcpy(output, begin, (input - begin) * sizeof(QChar));
            |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In file included from /home/rutledge/dev/qt6-dbg/qtbase/include/QtCore/qchar.h:1,
                       from /home/rutledge/dev/qt6-dbg/qtbase/include/QtCore/../../../../qt6/qtbase/src/corelib/text/qstring.h:50,
                       from /home/rutledge/dev/qt6-dbg/qtbase/include/QtCore/qstring.h:1,
                       from /home/rutledge/dev/qt6/qtbase/src/corelib/io/qurl.h:46,
                       from /home/rutledge/dev/qt6/qtbase/src/corelib/io/qurlrecode.cpp:40:
      /home/rutledge/dev/qt6-dbg/qtbase/include/QtCore/../../../../qt6/qtbase/src/corelib/text/qchar.h:84:21: note: ‘class QChar’ declared here
         84 | class Q_CORE_EXPORT QChar {
            |                     ^~~~~
      /home/rutledge/dev/qt6/qtbase/src/corelib/io/qurlrecode.cpp:604:19: warning: ‘void* memcpy(void*, const void*, size_t)’ copying an object of non-trivial type ‘class QChar’ from an array of ‘const char16_t’ [-Wclass-memaccess]
        604 |             memcpy(appendTo.begin() + origSize, begin, (end - begin) * sizeof(*end));
            |             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In file included from /home/rutledge/dev/qt6-dbg/qtbase/include/QtCore/qchar.h:1,
                       from /home/rutledge/dev/qt6-dbg/qtbase/include/QtCore/../../../../qt6/qtbase/src/corelib/text/qstring.h:50,
                       from /home/rutledge/dev/qt6-dbg/qtbase/include/QtCore/qstring.h:1,
                       from /home/rutledge/dev/qt6/qtbase/src/corelib/io/qurl.h:46,
                       from /home/rutledge/dev/qt6/qtbase/src/corelib/io/qurlrecode.cpp:40:
      /home/rutledge/dev/qt6-dbg/qtbase/include/QtCore/../../../../qt6/qtbase/src/corelib/text/qchar.h:84:21: note: ‘class QChar’ declared here
         84 | class Q_CORE_EXPORT QChar {
            |                     ^~~~~
      [900/14293] Building CXX object qtbase/src/corelib/CMakeFiles/Core.dir/io/qurlrecode.cpp.o
      FAILED: qtbase/src/corelib/CMakeFiles/Core.dir/io/qurlrecode.cpp.o 
      
          const char16_t *begin = in.utf16();
          const char16_t *end = begin + in.size();
      
          // fast check whether there's anything to be decoded in the first place
          const char16_t *input = QtPrivate::qustrchr(in, '%');
      
          if (Q_LIKELY(input == end))
              return 0;           // nothing to do, it was already decoded!
      
          // detach
          const int origSize = appendTo.size();
          appendTo.resize(origSize + (end - begin));
          QChar *output = appendTo.data() + origSize;
          memcpy(output, begin, (input - begin) * sizeof(QChar));
      

      That's from https://codereview.qt-project.org/c/qt/qtbase/+/368734

      Attachments

        Issue Links

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

          Activity

            People

              eugmes Ievgenii Meshcheriakov (Inactive)
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes