From d1ed8ac66e2b7c19a4e28a29be5cc36a544eaf3b Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Fri, 11 Feb 2022 09:08:23 -0800 Subject: [PATCH] Avoid compiler crash with Clang 6.0 Instead of C++17 structured bindings, use a plain `const auto&` and annotate arguments with comments instead. We still support Clang 6.0, as that is the compiler that ships with Ubuntu 18.04 LTS by default. PiperOrigin-RevId: 428016214 Change-Id: I3a43b2d47c6825ac4425d22018750282cfe23c1b --- sandboxed_api/util/status.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sandboxed_api/util/status.cc b/sandboxed_api/util/status.cc index 323915d..df93823 100644 --- a/sandboxed_api/util/status.cc +++ b/sandboxed_api/util/status.cc @@ -31,8 +31,11 @@ void SaveStatusToProto(const absl::Status& status, StatusProto* out) { absl::Status MakeStatusFromProto(const StatusProto& proto) { absl::Status status(static_cast(proto.code()), proto.message()); - for (const auto& [type_key, payload] : proto.payloads()) { - status.SetPayload(type_key, absl::Cord(payload)); + // Note: Using C++17 structured bindings instead of `entry` crashes Clang 6.0 + // on Ubuntu 18.04 (bionic). + for (const auto& entry : proto.payloads()) { + status.SetPayload(/*type_url=*/entry.first, + /*payload=*/absl::Cord(entry.second)); } return status; }