diff options
author | Evan Brown <ezb@google.com> | 2022-10-07 11:09:35 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-10-07 11:10:22 -0700 |
commit | 192e9834bc6f3aa52a0bad24ef96e658d9ce882f (patch) | |
tree | 15b667c4ffd47858053c4e3bb76c29fbdc775e2a /absl/container/internal | |
parent | d870260579a0f032548fc79dcb4ba7e2114be9f3 (diff) |
Add static_cast<void*> to the sources for trivial relocations to avoid spurious -Wdynamic-class-memaccess errors in the presence of other compilation errors.
PiperOrigin-RevId: 479625866
Change-Id: Ia10ad35a2f58ffb3f36f996d357d5e126b181e1c
Diffstat (limited to 'absl/container/internal')
-rw-r--r-- | absl/container/internal/common_policy_traits.h | 5 | ||||
-rw-r--r-- | absl/container/internal/container_memory.h | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/absl/container/internal/common_policy_traits.h b/absl/container/internal/common_policy_traits.h index c99e68f4..0fd4866e 100644 --- a/absl/container/internal/common_policy_traits.h +++ b/absl/container/internal/common_policy_traits.h @@ -93,11 +93,12 @@ struct common_policy_traits { slot_type* old_slot, char) { #if defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606 if (absl::is_trivially_relocatable<value_type>()) { - // TODO(b/247130232): remove cast after fixing class-memaccess warning. + // TODO(b/247130232,b/251814870): remove casts after fixing warnings. std::memcpy(static_cast<void*>( std::launder(const_cast<std::remove_const_t<value_type>*>( &element(new_slot)))), - &element(old_slot), sizeof(value_type)); + static_cast<const void*>(&element(old_slot)), + sizeof(value_type)); return; } #endif diff --git a/absl/container/internal/container_memory.h b/absl/container/internal/container_memory.h index c29c533b..bfa4ff93 100644 --- a/absl/container/internal/container_memory.h +++ b/absl/container/internal/container_memory.h @@ -428,9 +428,10 @@ struct map_slot_policy { emplace(new_slot); #if defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606 if (absl::is_trivially_relocatable<value_type>()) { - // TODO(b/247130232): remove cast after fixing class-memaccess warning. + // TODO(b/247130232,b/251814870): remove casts after fixing warnings. std::memcpy(static_cast<void*>(std::launder(&new_slot->value)), - &old_slot->value, sizeof(value_type)); + static_cast<const void*>(&old_slot->value), + sizeof(value_type)); return; } #endif |