Skip to content
Permalink
Browse files

Prevent compiler warning about writing to an object with no trivial c…

…opy-assignment
  • Loading branch information...
How Si Wei
How Si Wei committed Jun 27, 2019
1 parent 8b7d956 commit 95e5e934bc8154349fb70b18979bca69fd3121f2
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/sparsehash/sparsetable
@@ -1088,7 +1088,9 @@ class sparsegroup {
// This is equivalent to memmove(), but faster on my Intel P4,
// at least with gcc4.1 -O2 / glibc 2.3.6.
for (size_type i = settings.num_buckets; i > offset; --i)
memcpy(group + i, group + i-1, sizeof(*group));
// cast to void* to prevent compiler warnings about writing to an object
// with no trivial copy-assignment
memcpy(static_cast<void*>(group + i), group + i-1, sizeof(*group));
}

// Create space at group[offset], without special assumptions about value_type
@@ -1154,7 +1156,10 @@ class sparsegroup {
// at lesat with gcc4.1 -O2 / glibc 2.3.6.
assert(settings.num_buckets > 0);
for (size_type i = offset; i < settings.num_buckets-1; ++i)
memcpy(group + i, group + i+1, sizeof(*group)); // hopefully inlined!
// cast to void* to prevent compiler warnings about writing to an object
// with no trivial copy-assignment
// hopefully inlined!
memcpy(static_cast<void*>(group + i), group + i+1, sizeof(*group));
group = settings.realloc_or_die(group, settings.num_buckets-1);
}

0 comments on commit 95e5e93

Please sign in to comment.
You can’t perform that action at this time.