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

stringbuilder gcc 11 error: 'void* memcpy(void*, const void*, size_t)' copying an object of non-trivial type 'class QChar' from an array of 'const char16_t' [-Werror=class-memaccess]

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: 6.2.0 RC
    • Fix Version/s: 6.2.0
    • Labels:
      None
    • Environment:
      Arch Linux, gcc 11.1.0, cmake 3.21.2; ran configure and then ninja
    • Commits:
      64d3b9f6d11cae1aed0af3d0d69f2770b1a492ef (6.2), a20a4240668faa0e6c961b90266918628f9f5484 (dev)

      Description

      [4158/11242] Building CXX object qtdeclarative/src/qml/CMakeFiles/Qml.dir/jsruntime/qv4qobjectwrapper.cpp.o
      FAILED: qtdeclarative/src/qml/CMakeFiles/Qml.dir/jsruntime/qv4qobjectwrapper.cpp.o 
      /usr/lib/ccache/bin/c++ -DBUILDING_QT__ -DENABLE_ASSEMBLER_WX_EXCLUSIVE=1 -DENABLE_DFG_JIT=0 -DENABLE_DFG_JIT_UTILITY_METHODS=1 -DENABLE_JIT_CONSTANT_BLINDING=0 -DENABLE_LLINT=0 -DJS_EXPORT_PRIVATE="" -DQT_ASCII_CAST_WARNINGS -DQT_BUILDING_QT -DQT_BUILD_QML_LIB -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_MOC_COMPAT -DQT_NETWORK_LIB -DQT_NO_CAST_TO_ASCII -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -DQT_NO_INTEGER_EVENT_COORDINATES -DQT_NO_URL_CAST_FROM_STRING -DQT_USE_QSTRINGBUILDER -DQml_EXPORTS -DWTFInvokeCrashHook=qmlWTFInvokeCrashHook -DWTFReportAssertionFailure=qmlWTFReportAssertionFailure -DWTFReportAssertionFailureWithMessage=qmlWTFReportAssertionFailureWithMessage -DWTFReportBacktrace=qmlWTFReportBacktrace -DWTF_EXPORT_PRIVATE="" -DWTF_USE_UDIS86=0 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/home/rutledge/dev/qt-stabilizing-dbg/qtdeclarative/src/qml/Qml_autogen/include -I/home/rutledge/dev/qt-stabilizing-dbg/qtbase/include -I/home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtQml -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml -I/home/rutledge/dev/qt-stabilizing-dbg/qtdeclarative/src/qml -I/home/rutledge/dev/qt-stabilizing-dbg/qtdeclarative/src/qml/compiler -I/home/rutledge/dev/qt-stabilizing-dbg/qtdeclarative/src/qml/jsruntime -I/home/rutledge/dev/qt-stabilizing-dbg/qtdeclarative/src/qml/memory -I/home/rutledge/dev/qt-stabilizing-dbg/qtdeclarative/src/qml/qmldirparser -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/../3rdparty/masm -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/../3rdparty/masm/assembler -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/../3rdparty/masm/disassembler -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/../3rdparty/masm/disassembler/udis86 -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/../3rdparty/masm/jit -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/../3rdparty/masm/runtime -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/../3rdparty/masm/stubs -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/../3rdparty/masm/stubs/runtime -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/../3rdparty/masm/stubs/wtf -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/../3rdparty/masm/wtf -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/.generated -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/compiler -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/debugger -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/jsruntime -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/memory -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/qmldirparser -I/home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtQml/6.2.0 -I/home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtQml/6.2.0/QtQml -I/home/rutledge/dev/qt-stabilizing-dbg/qtbase/src/corelib -I/home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/6.2.0 -I/home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/6.2.0/QtCore -I/home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore -I/home/rutledge/dev/qt-stabilizing-dbg/qtbase/mkspecs/linux-g++ -I/home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtNetwork -I/home/rutledge/dev/qt-stabilizing-dbg/qtdeclarative/src/qml/.generated/debug -I/home/rutledge/dev/qt-stabilizing-dbg/qtdeclarative/src/qml/jit -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/jit -I/home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/animations -g -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -fno-exceptions -fPIC -Werror -Wno-error=cpp -Wno-error=deprecated-declarations -Wno-error=strict-overflow -Wno-error=implicit-fallthrough -Wno-error=deprecated-copy -Wno-error=redundant-move -Wno-error=init-list-lifetime -Wno-error=format-overflow -Wno-error=stringop-overflow -Wno-error=deprecated-enum-enum-conversion -Wno-error=deprecated-enum-float-conversion -no-integrated-cpp -Wno-implicit-fallthrough -Wsuggest-override -std=c++17 -MD -MT qtdeclarative/src/qml/CMakeFiles/Qml.dir/jsruntime/qv4qobjectwrapper.cpp.o -MF qtdeclarative/src/qml/CMakeFiles/Qml.dir/jsruntime/qv4qobjectwrapper.cpp.o.d -o qtdeclarative/src/qml/CMakeFiles/Qml.dir/jsruntime/qv4qobjectwrapper.cpp.o -c /home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
      In file included from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/qstringbuilder.h:1,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/text/qstring.h:1583,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/qstring.h:1,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/tools/qhashfunctions.h:44,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/qhashfunctions.h:1,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/tools/qvarlengtharray.h:47,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/qvarlengtharray.h:1,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/kernel/qmetatype.h:49,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/qmetatype.h:1,
                       from /home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper_p.h:55,
                       from /home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp:40:
      /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/text/qstringbuilder.h: In instantiation of 'static void QConcatenable<const char16_t [N]>::appendTo(const char16_t*, QChar*&) [with long long int N = 6]':
      /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/text/qstringbuilder.h:402:35:   required from 'static void QConcatenable<QStringBuilder< <template-parameter-1-1>, <template-parameter-1-2> > >::appendTo(const type&, T*&) [with T = QChar; A = char16_t [6]; B = QString; QConcatenable<QStringBuilder< <template-parameter-1-1>, <template-parameter-1-2> > >::type = QStringBuilder<char16_t [6], QString>]'
      /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/text/qstringbuilder.h:460:52:   required from 'QString& operator+=(QString&, const QStringBuilder<A, B>&) [with A = char16_t [6]; B = QString]'
      /home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp:1749:75:   required from here
      /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/text/qstringbuilder.h:338:15: error: 'void* memcpy(void*, const void*, size_t)' copying an object of non-trivial type 'class QChar' from an array of 'const char16_t' [-Werror=class-memaccess]
        338 |         memcpy(out, a, (N - 1) * sizeof(char16_t));
            |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In file included from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/qchar.h:1,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/text/qstring.h:50,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/qstring.h:1,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/tools/qhashfunctions.h:44,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/qhashfunctions.h:1,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/tools/qvarlengtharray.h:47,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/qvarlengtharray.h:1,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/kernel/qmetatype.h:49,
                       from /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/qmetatype.h:1,
                       from /home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper_p.h:55,
                       from /home/rutledge/dev/qt-stabilizing/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp:40:
      /home/rutledge/dev/qt-stabilizing-dbg/qtbase/include/QtCore/../../../../qt-stabilizing/qtbase/src/corelib/text/qchar.h:84:46: note: 'class QChar' declared here
         84 | class Q_CORE_EXPORT QChar {
            |                                              ^    
      cc1plus: all warnings being treated as errors
      [4191/11242] Building CXX object qtdeclarative/src/qml/CMakeFiles/Qml.dir/qml/qqmlpropertyvalidator.cpp.o
      ninja: build stopped: subcommand failed.
      
          if (best && best->isValid()) {
              return best;
          } else {
              QString error = QLatin1String("Unable to determine callable overload.  Candidates are:");
              for (int i = 0; i < methodCount; ++i) {
                  for (int i = 0; i < methodCount; ++i) {
                      const QQmlPropertyData &candidate = methods[i];
                      const QMetaMethod m = candidate.isConstructor()
                                            ? object.metaObject()->constructor(candidate.coreIndex())
                                            : object.metaObject()->method(candidate.coreIndex());
                      error += u"\n    " + QString::fromUtf8(m.methodSignature()); // <--- from here
                  }
              }
      
              engine->throwError(error);
              return nullptr;
          }
      

      that looks like it ought to be OK, but something about what stringbuilder does with it...

      template <qsizetype N> struct QConcatenable<const char16_t[N]> : private QAbstractConcatenable
      {
          using type = const char16_t[N];
          using ConvertTo = QString;
          enum { ExactSize = true };
          static qsizetype size(const char16_t[N]) { return N - 1; }
          static void appendTo(const char16_t a[N], QChar *&out)
          {
              memcpy(out, a, (N - 1) * sizeof(char16_t)); // <--- the memcpy
              out += N - 1;
          }
      };
      

      that's not a recent change either, it's from https://codereview.qt-project.org/c/qt/qtbase/+/190197

        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:
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes