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

Prevent compiler warning about writing to an object with no trivial copy-assignment #153

Merged
merged 1 commit into from Jul 18, 2019

Conversation

@howsiwei
Copy link

commented Jun 28, 2019

Fix sparetable part of #149.

The warnings are caused by differences between google::has_trivial_copy * google::has_trivial_destructor and std::is_trivially_copyable * std::is_trivially_destructible, henceforth referred to as google trivial and standard trivial.

In particularly, this causes warning in time_hash_map.cc because

  1. If T and U are google trivial, pair<T, U> is also google trivial. However, pair is not standard trivial.
  2. HashObject is declared to be google trivial in time_hash_map.cc explicitly even though it implements custom copy constructor and copy assignment.

This PR prevents the warnings by casting pointers to void* first before memcpy. This is fine as long as a google trivial type is really trivially copyable and destructible.

@howsiwei

This comment has been minimized.

Copy link
Author

commented Jul 18, 2019

@Dekken Would you please have a look at this and consider merging it?

@Dekken Dekken merged commit f93c0c6 into sparsehash:master Jul 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.