Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings/errors on GCC 7/8 (-Wclass-memaccess, -Wsign-conversion, -Wformat-overflow) #1323

Merged
merged 3 commits into from Jul 16, 2018

Conversation

@pah
Copy link
Contributor

@pah pah commented Jul 15, 2018

Recent GCC versions warn about using memcpy/memmove to write to a class pointer (-Wclass-memaccess). This has been reported multiple times now, but the suppressions in the master branch are not complete.

This PR avoids the warnings by casting the destination pointer to void* first.

Closes #1086.
Closes #1205.
Closes #1246.

Additional warnings are fixed / suppressed as discovered during testing:

  • Fix -Wsign-conversion warnings/errors (a26267d)
  • Suppress -Wformat-overflow warning/error (1525116)
Recent GCC versions warn about using memcpy/memmove to
write to a class pointer (-Wclass-memaccess).

Avoid the warnings by casting to void* first.

Closes #1086.
Closes #1205.
Closes #1246.
@coveralls
Copy link

@coveralls coveralls commented Jul 15, 2018

Coverage Status

Coverage increased (+0.001%) to 99.922% when pulling 1525116 on pah:fix-memaccess into 4b4583b on Tencent:master.

pah added 2 commits Jul 15, 2018
GCC 8 (incorrectly) warns about sign conversions in (constant)
array size expressions:

error: conversion to 'long unsigned int' from 'int' may
change the sign of the result [-Werror=sign-conversion]
     char schemaBuffer_[128 * 1024];

Make these expressions unsigned by adding a 'u' suffix to
the first operands.
GCC 7 and later warn about overflow/truncation when using
sprintf and related functions with fixed-size buffers.

Suppress the warning in schematest.cpp.
@pah pah changed the title Fix -Wclass-memaccess warnings/errors Fix warnings/errors on GCC 7/8 (-Wclass-memaccess, -Wsign-conversion, -Wformat-overflow) Jul 15, 2018
@miloyip miloyip merged commit 2bbd33b into Tencent:master Jul 16, 2018
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.001%) to 99.922%
Details
@miloyip
Copy link
Collaborator

@miloyip miloyip commented Jul 16, 2018

Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.