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

Compiler warning on realloc call within sparsepp. #90

Open
rob-p opened this issue Jun 15, 2020 · 1 comment
Open

Compiler warning on realloc call within sparsepp. #90

rob-p opened this issue Jun 15, 2020 · 1 comment

Comments

@rob-p
Copy link
Contributor

rob-p commented Jun 15, 2020

Hi @greg7mdp,

Thanks again for both sparsepp and parallel-hashmap! I wanted to report a (fairly verbose) compiler warning I get when using sparsepp within some of our code. Specifically, I get a a compiler trace that ends in the following warning. It looks like the root cause is using realloc on a type that is not trivially copyable. Any suggestions on how to fix this?

sparsepp/spp_utils.h:425:51: warning: 'void* realloc(void*, size_t)' moving an object of non-trivially copyable type 'struct std::pair<const std::pair<unsigned int, unsigned int>, unsigned int>'; use 'new' and 'delete' instead [-Wclass-memaccess]
  425 |         pointer res = static_cast<pointer>(realloc(p, new_size * sizeof(T)));
@greg7mdp
Copy link
Owner

greg7mdp commented Nov 23, 2020

Hi @rob-p,

Thanks for the kind words!

This type struct std::pair<const std::pair<unsigned int, unsigned int>, unsigned int> is in fact safe to reallocate, even if the c++11 API std::is_trivially_copyable returns false. sparsepp doesn't require a c++11 compiler and uses the internal spp::is_relocatable.

As far as I can tell this warning can safely be ignored.

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

No branches or pull requests

2 participants