adobe / adobe/XMP-Toolkit-SDK

Clang complains about -Wnontrivial-memcall

Open
#111 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
262
Forks
110
PR merge metrics
No merged PRs in 30d

Description

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*.

Contributor guide

Open the contributing guide

Research direction

Inspect the memcpy calls in external/XMP-Toolkit-SDK/XMPFiles/source/FormatSupport/TIFF_Support.hpp and PSIR_Support.hpp, along with the related call in external/swiftshader/third_party/llvm-16.0/llvm/lib/ExecutionEngine/ExecutionEngine.cpp. Build with a newer Clang using -Wnontrivial-memcall enabled, and consider the explicit void-pointer casts shown in the diagnostics; done means these warnings no longer fail the build.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.