diff options
author | Derek Mauro <dmauro@google.com> | 2023-11-14 11:49:03 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-11-14 11:49:49 -0800 |
commit | 1415840502f38952e63c1c6e4892f6e69ce7bc13 (patch) | |
tree | a433572dc9519ad396388955dd921a9e948c3c8f /absl/algorithm/container_test.cc | |
parent | 4a0255b16e85233849ec34c48f428ad8d2936eda (diff) | |
download | abseil-1415840502f38952e63c1c6e4892f6e69ce7bc13.tar.gz abseil-1415840502f38952e63c1c6e4892f6e69ce7bc13.tar.bz2 abseil-1415840502f38952e63c1c6e4892f6e69ce7bc13.zip |
Don't allow AbslHashValue() to take a C-style array parameter. The
current behavior of decaying the array to a pointer and hashing the
pointer can lead to subtle bugs.
The most common potential error is passing a C-string literal. Hashing
the char pointer in those cases is correct only if the string literals
are guaranteed to be deduplicated, which is dangerous to rely on even
if true (and the call sites in header files require deduplication
across translation units). After this change, these call-sites
requires wrapping the literal in absl::string_view.
This is a breaking change for code doing something like
absl::HashOf("string");
Instead, this should be changed to
absl::HashOf(absl::string_view("string"));
PiperOrigin-RevId: 582393585
Change-Id: I3810c07b5b74bf153cb62a7beedce243be5a69ee
Diffstat (limited to 'absl/algorithm/container_test.cc')
0 files changed, 0 insertions, 0 deletions