From 2716c6faa46f346b66fe7af5219d611b369d42e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 23 Jun 2021 14:37:01 +0300 Subject: [PATCH] [flang] Tweak the conditions for the GCC 7/libstdc++ workaround This adjusts the workaround from D104731. The issue lies in libstdc++'s classes, not GCC itself, and manifests itself in the same way if building e.g. with clang while using libstdc++ headers from GCC 7 (e.g. if building with Clang on Ubuntu 18.04, while using the system default C++ library). Therefore, change the condition to look for the version of libstdc++ instead of the compiler. Differential Revision: https://reviews.llvm.org/D104779 --- flang/include/flang/Evaluate/type.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flang/include/flang/Evaluate/type.h b/flang/include/flang/Evaluate/type.h index 6ab09f60789d..a57d8107b7e3 100644 --- a/flang/include/flang/Evaluate/type.h +++ b/flang/include/flang/Evaluate/type.h @@ -142,7 +142,7 @@ public: return charLengthParamValue_; } constexpr std::optional knownLength() const { -#if !__clang__ && __GNUC__ == 7 +#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE == 7 if (knownLength_ < 0) { return std::nullopt; } @@ -222,7 +222,7 @@ private: TypeCategory category_{TypeCategory::Derived}; // overridable default int kind_{0}; const semantics::ParamValue *charLengthParamValue_{nullptr}; -#if !__clang__ && __GNUC__ == 7 +#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE == 7 // GCC 7's optional<> lacks a constexpr operator= std::int64_t knownLength_{-1}; #else