Skip to content

Fix -Wnontrivial-memcall warning#112

Open
Sharjeel-Khan wants to merge 1 commit intoadobe:mainfrom
Sharjeel-Khan:warning-fix
Open

Fix -Wnontrivial-memcall warning#112
Sharjeel-Khan wants to merge 1 commit intoadobe:mainfrom
Sharjeel-Khan:warning-fix

Conversation

@Sharjeel-Khan
Copy link

Description

Memcall functions work at the byte level so they don't know about C++semantics and these C++ objects might not have trivial constructors or destructors. Clang has started complaining about this with this warning (-Wnontrivial-memcall). I silenced the warning by explicitly casting the pointer to void* with static_cast. I did this fix because it seems the code developer knows the consequences with using memcall functions with C++ objects.

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: 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.
| ^

Related Issue

#111

Motivation and Context

How Has This Been Tested?

I built this repo with the change in Android and warnings disappear.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Memcall functions work at the byte level so they don't know about
C++semantics and these C++ objects might not have trivial constructors
or destructors. I silenced the warning by explicitly casting the pointer
to void* with static_cast. I did this fix because it seems the code
developer knows the consequences with using memcall functions with C++
objects.

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:
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.
      |                                  ^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant