summaryrefslogtreecommitdiff
path: root/absl/base/const_init.h
diff options
context:
space:
mode:
authorGravatar Derek Mauro <dmauro@google.com>2023-11-14 11:49:03 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2023-11-14 11:49:49 -0800
commit1415840502f38952e63c1c6e4892f6e69ce7bc13 (patch)
treea433572dc9519ad396388955dd921a9e948c3c8f /absl/base/const_init.h
parent4a0255b16e85233849ec34c48f428ad8d2936eda (diff)
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/base/const_init.h')
0 files changed, 0 insertions, 0 deletions