Skip to content

Clang complains about -Wnontrivial-memcall #111

@Sharjeel-Khan

Description

@Sharjeel-Khan

Newer versions of Clang have a warning called nontrivial-memcall that complains using memcall functions with particular C++ objects. It seems to complain with some memcpy functions in this repo:

external/XMP-Toolkit-SDK/XMPFiles/source/FormatSupport/TIFF_Support.hpp:941:13: error: first argument in call to 'memcpy' is a pointer to non-trivially copyable type 'TIFF_FileWriter::InternalTagInfo'
[-Werror,-Wnontrivial-memcall]
  941 |                         memcpy ( this, &in, sizeof(*this) );
// AUDIT: Use of sizeof(InternalTagInfo) is safe.
      |                                  ^
external/XMP-Toolkit-SDK/XMPFiles/source/FormatSupport/PSIR_Support.hpp:289:13: note: explicitly cast the pointer to silence this warning
  289 |                         memcpy ( this, &in, sizeof(*this) );    // AUDIT: Use of sizeof(InternalRsrcInfo) is safe.
      |                                  ^
      |                                  (void*)

external/XMP-Toolkit-SDK/XMPFiles/source/FormatSupport/PSIR_Support.hpp:289:13: error: first argument in call to 'memcpy' is a pointer to non-trivially copyable type 'PSIR_FileWriter::InternalRsrcInfo'
[-Werror,-Wnontrivial-memcall]
  289 |                         memcpy ( this, &in, sizeof(*this) );
// AUDIT: Use of sizeof(InternalRsrcInfo) is safe.
      |                                  ^
external/swiftshader/third_party/llvm-16.0/llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1036:12: note: explicitly cast the pointer to silence this warning
 1036 |     memcpy(Ptr, Val.IntVal.getRawData(), 10);
      |            ^
      |            (void*)

The easiest fix as mentioned in the note is to explicitly case it to void*.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions