Roll abseil_revision 2a042b082c..c59e7e59f5

Change Log:
https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+log/2a042b082c..c59e7e59f5
Full diff:
https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+/2a042b082c..c59e7e59f5

No build.gn changes (benchmark only target change)
No .def changes

Bug: None
Change-Id: I540dc7db4b8b7d13b9793729526fc20533654b95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3401458
Commit-Queue: Danil Chapovalov <danilchap@chromium.org>
Auto-Submit: Danil Chapovalov <danilchap@chromium.org>
Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
Commit-Queue: Mirko Bonadei <mbonadei@chromium.org>
Cr-Commit-Position: refs/heads/main@{#960994}
NOKEYCHECK=True
GitOrigin-RevId: 2fb0e8d0ec6e356567a5718770129db001630f4e
diff --git a/README.chromium b/README.chromium
index f8eb8ce..f1b540b 100644
--- a/README.chromium
+++ b/README.chromium
@@ -4,7 +4,7 @@
 License: Apache 2.0
 License File: LICENSE
 Version: 0
-Revision: 2a042b082ca6fc8592ec98d800012fc03c965c15
+Revision: c59e7e59f5d29619ddc07fcb59be3dcba9585814
 Security Critical: yes
 
 Description:
diff --git a/absl/base/casts.h b/absl/base/casts.h
index 83c6912..b16af23 100644
--- a/absl/base/casts.h
+++ b/absl/base/casts.h
@@ -105,47 +105,50 @@
 
 // bit_cast()
 //
-// Performs a bitwise cast on a type without changing the underlying bit
-// representation of that type's value. The two types must be of the same size
-// and both types must be trivially copyable. As with most casts, use with
-// caution. A `bit_cast()` might be needed when you need to temporarily treat a
-// type as some other type, such as in the following cases:
+// Creates a value of the new type `Dest` whose representation is the same as
+// that of the argument, which is of (deduced) type `Source` (a "bitwise cast";
+// every bit in the value representation of the result is equal to the
+// corresponding bit in the object representation of the source). Source and
+// destination types must be of the same size, and both types must be trivially
+// copyable.
 //
-//    * Serialization (casting temporarily to `char *` for those purposes is
-//      always allowed by the C++ standard)
-//    * Managing the individual bits of a type within mathematical operations
-//      that are not normally accessible through that type
-//    * Casting non-pointer types to pointer types (casting the other way is
-//      allowed by `reinterpret_cast()` but round-trips cannot occur the other
-//      way).
-//
-// Example:
+// As with most casts, use with caution. A `bit_cast()` might be needed when you
+// need to treat a value as the value of some other type, for example, to access
+// the individual bits of an object which are not normally accessible through
+// the object's type, such as for working with the binary representation of a
+// floating point value:
 //
 //   float f = 3.14159265358979;
 //   int i = bit_cast<int32_t>(f);
 //   // i = 0x40490fdb
 //
-// Casting non-pointer types to pointer types and then dereferencing them
-// traditionally produces undefined behavior.
+// Reinterpreting and accessing a value directly as a different type (as shown
+// below) usually results in undefined behavior.
 //
 // Example:
 //
 //   // WRONG
-//   float f = 3.14159265358979;            // WRONG
-//   int i = * reinterpret_cast<int*>(&f);  // WRONG
+//   float f = 3.14159265358979;
+//   int i = reinterpret_cast<int&>(f);    // Wrong
+//   int j = *reinterpret_cast<int*>(&f);  // Equally wrong
+//   int k = *bit_cast<int*>(&f);          // Equally wrong
 //
-// The address-casting method produces undefined behavior according to the ISO
-// C++ specification section [basic.lval]. Roughly, this section says: if an
-// object in memory has one type, and a program accesses it with a different
-// type, the result is undefined behavior for most values of "different type".
+// Reinterpret-casting results in undefined behavior according to the ISO C++
+// specification, section [basic.lval]. Roughly, this section says: if an object
+// in memory has one type, and a program accesses it with a different type, the
+// result is undefined behavior for most "different type".
+//
+// Using bit_cast on a pointer and then dereferencing it is no better than using
+// reinterpret_cast. You should only use bit_cast on the value itself.
 //
 // Such casting results in type punning: holding an object in memory of one type
 // and reading its bits back using a different type. A `bit_cast()` avoids this
-// issue by implementing its casts using `memcpy()`, which avoids introducing
-// this undefined behavior.
+// issue by copying the object representation to a new value, which avoids
+// introducing this undefined behavior (since the original value is never
+// accessed in the wrong way).
 //
-// NOTE: The requirements here are more strict than the bit_cast of standard
-// proposal p0476 due to the need for workarounds and lack of intrinsics.
+// NOTE: The requirements here are stricter than the bit_cast of standard
+// proposal P0476 due to the need for workarounds and lack of intrinsics.
 // Specifically, this implementation also requires `Dest` to be
 // default-constructible.
 template <
diff --git a/absl/container/internal/compressed_tuple_test.cc b/absl/container/internal/compressed_tuple_test.cc
index 62a7483..74111f9 100644
--- a/absl/container/internal/compressed_tuple_test.cc
+++ b/absl/container/internal/compressed_tuple_test.cc
@@ -403,6 +403,16 @@
 }
 #endif
 
+// TODO(b/214288561): enable this test.
+TEST(CompressedTupleTest, DISABLED_NestedEbo) {
+  struct Empty1 {};
+  struct Empty2 {};
+  CompressedTuple<Empty1, CompressedTuple<Empty2>, int> x;
+  CompressedTuple<Empty1, Empty2, int> y;
+  // Currently fails with sizeof(x) == 8, sizeof(y) == 4.
+  EXPECT_EQ(sizeof(x), sizeof(y));
+}
+
 }  // namespace
 }  // namespace container_internal
 ABSL_NAMESPACE_END
diff --git a/absl/numeric/BUILD.bazel b/absl/numeric/BUILD.bazel
index 1f9e0f2..eaa27df 100644
--- a/absl/numeric/BUILD.bazel
+++ b/absl/numeric/BUILD.bazel
@@ -37,6 +37,20 @@
     ],
 )
 
+cc_binary(
+    name = "bits_benchmark",
+    testonly = 1,
+    srcs = ["bits_benchmark.cc"],
+    copts = ABSL_DEFAULT_COPTS,
+    linkopts = ABSL_DEFAULT_LINKOPTS,
+    deps = [
+        ":bits",
+        "//absl/base:core_headers",
+        "//absl/random",
+        "@com_github_google_benchmark//:benchmark_main",
+    ],
+)
+
 cc_test(
     name = "bits_test",
     size = "small",
diff --git a/absl/numeric/bits_benchmark.cc b/absl/numeric/bits_benchmark.cc
new file mode 100644
index 0000000..3de1dbf
--- /dev/null
+++ b/absl/numeric/bits_benchmark.cc
@@ -0,0 +1,73 @@
+// Copyright 2022 The Abseil Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <vector>
+
+#include "benchmark/benchmark.h"
+#include "absl/base/optimization.h"
+#include "absl/numeric/bits.h"
+#include "absl/random/random.h"
+
+namespace absl {
+namespace {
+
+template <typename T>
+static void BM_bitwidth(benchmark::State& state) {
+  const int count = state.range(0);
+
+  absl::BitGen rng;
+  std::vector<T> values;
+  values.reserve(count);
+  for (int i = 0; i < count; ++i) {
+    values.push_back(absl::Uniform<T>(rng, 0, std::numeric_limits<T>::max()));
+  }
+
+  while (state.KeepRunningBatch(count)) {
+    for (int i = 0; i < count; ++i) {
+      benchmark::DoNotOptimize(values[i]);
+    }
+  }
+}
+BENCHMARK_TEMPLATE(BM_bitwidth, uint8_t)->Range(1, 1 << 20);
+BENCHMARK_TEMPLATE(BM_bitwidth, uint16_t)->Range(1, 1 << 20);
+BENCHMARK_TEMPLATE(BM_bitwidth, uint32_t)->Range(1, 1 << 20);
+BENCHMARK_TEMPLATE(BM_bitwidth, uint64_t)->Range(1, 1 << 20);
+
+template <typename T>
+static void BM_bitwidth_nonzero(benchmark::State& state) {
+  const int count = state.range(0);
+
+  absl::BitGen rng;
+  std::vector<T> values;
+  values.reserve(count);
+  for (int i = 0; i < count; ++i) {
+    values.push_back(absl::Uniform<T>(rng, 1, std::numeric_limits<T>::max()));
+  }
+
+  while (state.KeepRunningBatch(count)) {
+    for (int i = 0; i < count; ++i) {
+      const T value = values[i];
+      ABSL_INTERNAL_ASSUME(value > 0);
+      benchmark::DoNotOptimize(value);
+    }
+  }
+}
+BENCHMARK_TEMPLATE(BM_bitwidth_nonzero, uint8_t)->Range(1, 1 << 20);
+BENCHMARK_TEMPLATE(BM_bitwidth_nonzero, uint16_t)->Range(1, 1 << 20);
+BENCHMARK_TEMPLATE(BM_bitwidth_nonzero, uint32_t)->Range(1, 1 << 20);
+BENCHMARK_TEMPLATE(BM_bitwidth_nonzero, uint64_t)->Range(1, 1 << 20);
+
+}  // namespace
+}  // namespace absl
diff --git a/absl/random/internal/distribution_caller.h b/absl/random/internal/distribution_caller.h
index fc81b78..f1ad5cc 100644
--- a/absl/random/internal/distribution_caller.h
+++ b/absl/random/internal/distribution_caller.h
@@ -32,6 +32,8 @@
 // to intercept such calls.
 template <typename URBG>
 struct DistributionCaller {
+  static_assert(!std::is_pointer<URBG>::value,
+                "You must pass a reference, not a pointer.");
   // SFINAE to detect whether the URBG type includes a member matching
   // bool InvokeMock(base_internal::FastTypeIdType, void*, void*).
   //
diff --git a/ci/linux_clang-latest_libcxx_asan_bazel.sh b/ci/linux_clang-latest_libcxx_asan_bazel.sh
index 5245933..0605e2b 100755
--- a/ci/linux_clang-latest_libcxx_asan_bazel.sh
+++ b/ci/linux_clang-latest_libcxx_asan_bazel.sh
@@ -70,8 +70,8 @@
         --rm \
         -e CC="/opt/llvm/clang/bin/clang" \
         -e BAZEL_CXXOPTS="-std=${std}:-nostdinc++" \
-        -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx/lib:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx/lib" \
-        -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx/include/c++/v1" \
+        -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx/lib/x86_64-unknown-linux-gnu:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx/lib/x86_64-unknown-linux-gnu" \
+        -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx/include/x86_64-unknown-linux-gnu/c++/v1:/opt/llvm/libcxx/include/c++/v1" \
         ${DOCKER_EXTRA_ARGS:-} \
         ${DOCKER_CONTAINER} \
         /usr/local/bin/bazel test ... \
diff --git a/ci/linux_clang-latest_libcxx_bazel.sh b/ci/linux_clang-latest_libcxx_bazel.sh
index e0fe653..0051774 100755
--- a/ci/linux_clang-latest_libcxx_bazel.sh
+++ b/ci/linux_clang-latest_libcxx_bazel.sh
@@ -71,8 +71,8 @@
         --rm \
         -e CC="/opt/llvm/clang/bin/clang" \
         -e BAZEL_CXXOPTS="-std=${std}:-nostdinc++" \
-        -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx/lib:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx/lib" \
-        -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx/include/c++/v1" \
+        -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx/lib/x86_64-unknown-linux-gnu:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx/lib/x86_64-unknown-linux-gnu" \
+        -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx/include/x86_64-unknown-linux-gnu/c++/v1:/opt/llvm/libcxx/include/c++/v1" \
         ${DOCKER_EXTRA_ARGS:-} \
         ${DOCKER_CONTAINER} \
         /bin/sh -c "
diff --git a/ci/linux_clang-latest_libcxx_tsan_bazel.sh b/ci/linux_clang-latest_libcxx_tsan_bazel.sh
index 555f6b1..da4fcd0 100755
--- a/ci/linux_clang-latest_libcxx_tsan_bazel.sh
+++ b/ci/linux_clang-latest_libcxx_tsan_bazel.sh
@@ -70,8 +70,8 @@
         --rm \
         -e CC="/opt/llvm/clang/bin/clang" \
         -e BAZEL_CXXOPTS="-std=${std}:-nostdinc++" \
-        -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx-tsan/lib:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx-tsan/lib" \
-        -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx-tsan/include/c++/v1" \
+        -e BAZEL_LINKOPTS="-L/opt/llvm/libcxx-tsan/lib/x86_64-unknown-linux-gnu:-lc++:-lc++abi:-lm:-Wl,-rpath=/opt/llvm/libcxx-tsan/lib/x86_64-unknown-linux-gnu" \
+        -e CPLUS_INCLUDE_PATH="/opt/llvm/libcxx-tsan/include/x86_64-unknown-linux-gnu/c++/v1:/opt/llvm/libcxx-tsan/include/c++/v1" \
         ${DOCKER_EXTRA_ARGS:-} \
         ${DOCKER_CONTAINER} \
         /usr/local/bin/bazel test ... \
diff --git a/ci/linux_docker_containers.sh b/ci/linux_docker_containers.sh
index 32865b8..37be531 100644
--- a/ci/linux_docker_containers.sh
+++ b/ci/linux_docker_containers.sh
@@ -16,6 +16,6 @@
 # Test scripts should source this file to get the identifiers.
 
 readonly LINUX_ALPINE_CONTAINER="gcr.io/google.com/absl-177019/alpine:20201026"
-readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20210617"
-readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20210617"
+readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20220113"
+readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20220113"
 readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20210617"