diff options
author | Dino Radakovic <dinor@google.com> | 2024-03-15 14:36:31 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-03-15 14:37:38 -0700 |
commit | 56d3f227154af7a646302ae4a0891f14a2d3616b (patch) | |
tree | c58ea6311696d1861184620d61e51a2931a226a6 /absl/container/internal | |
parent | 153186b6931d0755448da8d200e1b8e43acede48 (diff) | |
download | abseil-56d3f227154af7a646302ae4a0891f14a2d3616b.tar.gz abseil-56d3f227154af7a646302ae4a0891f14a2d3616b.tar.bz2 abseil-56d3f227154af7a646302ae4a0891f14a2d3616b.zip |
`layout`: Mark parameter of Slices with ABSL_ATTRIBUTE_UNUSED, remove old workaround
The workaround was added for a bug in GCC < 6.1., which had since been fixed. Abseil only [supports](https://github.com/google/oss-policies-info/blob/9a9bfe8a4a12be20757497074fc2f0ecb77438ad/foundational-cxx-support-matrix.md) GCC > 7.3.1.
However, removing the workaround still trips even more recent GCC, such as 13.1. When `SizeSeq` is empty, `p` is not actually used.
Marking it as `ABSL_ATTRIBUTE_UNUSED` silences the GCC warning for that case too.
We could disable `Slices` altogether when `SizeSeq` is empty, but that would be a breaking change (even though this API is internal), and possibly hurt generic programming use (they'd have to check if their parameter packs are empty).
PiperOrigin-RevId: 616245873
Change-Id: I77f7b0b921dfd63fb01c5223851ad1d8a7da233b
Diffstat (limited to 'absl/container/internal')
-rw-r--r-- | absl/container/internal/layout.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/absl/container/internal/layout.h b/absl/container/internal/layout.h index aa42a8ec..341c8262 100644 --- a/absl/container/internal/layout.h +++ b/absl/container/internal/layout.h @@ -171,6 +171,7 @@ #include <typeinfo> #include <utility> +#include "absl/base/attributes.h" #include "absl/base/config.h" #include "absl/debugging/internal/demangle.h" #include "absl/meta/type_traits.h" @@ -559,11 +560,11 @@ class LayoutImpl<std::tuple<Elements...>, absl::index_sequence<SizeSeq...>, // // Note: We're not using ElementType alias here because it does not compile // under MSVC. + // + // Note: We mark the parameter as unused because GCC detects it is not used + // when `SizeSeq` is empty [-Werror=unused-but-set-parameter]. template <class Char> - auto Slices(Char* p) const { - // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63875 (fixed - // in 6.1). - (void)p; + auto Slices(ABSL_ATTRIBUTE_UNUSED Char* p) const { return std::tuple<SliceType<CopyConst<Char, ElementType<SizeSeq>>>...>( Slice<SizeSeq>(p)...); } |