Commit 56d3f227 by Dino Radakovic Committed by Copybara-Service

`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
parent 153186b6
......@@ -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)...);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment