summaryrefslogtreecommitdiff
path: root/absl/types/optional_test.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-03-03 06:35:20 -0800
committerGravatar dinord <dino.radakovich@gmail.com>2022-03-03 09:43:16 -0500
commitec33f404bb16564a9aea3044cd8504d6885165b0 (patch)
tree42df609290f44528dff6d780261cf849cc8e5fee /absl/types/optional_test.cc
parentdfc3fa9b5ae8b204ac83e3f06e4e8626f9bb2bc2 (diff)
Export of internal Abseil changes
-- f2ffea8ae1c1b152b63bf561375cfb6eb6b9dbe5 by Derek Mauro <dmauro@google.com>: Internal change PiperOrigin-RevId: 432180490 Change-Id: I5e318e1d06fe26eee08920fe39f8a6285eb8e217 -- e5d0de4b3293833eab3f77252a091ac4ed74b210 by Derek Mauro <dmauro@google.com>: absl::optional - Add a workaround for an internal compiler error in GCC5 though GCC10 PiperOrigin-RevId: 432047437 Change-Id: I524a9098dadc116d8a423dd66f7ec5ee894f2874 GitOrigin-RevId: f2ffea8ae1c1b152b63bf561375cfb6eb6b9dbe5
Diffstat (limited to 'absl/types/optional_test.cc')
-rw-r--r--absl/types/optional_test.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/absl/types/optional_test.cc b/absl/types/optional_test.cc
index 7ef142cb..1846e695 100644
--- a/absl/types/optional_test.cc
+++ b/absl/types/optional_test.cc
@@ -27,6 +27,32 @@
#include "absl/meta/type_traits.h"
#include "absl/strings/string_view.h"
+// The following types help test an internal compiler error in GCC5 though
+// GCC10. The case OptionalTest.InternalCompilerErrorInGcc5ToGcc10 crashes the
+// compiler without a workaround. This test case should remain at the beginning
+// of the file as the internal compiler error is sensitive to other constructs
+// in this file.
+template <class T, class...>
+using GccIceHelper1 = T;
+template <typename T>
+struct GccIceHelper2 {};
+template <typename T>
+class GccIce {
+ template <typename U,
+ typename SecondTemplateArgHasToExistForSomeReason = void,
+ typename DependentType = void,
+ typename = std::is_assignable<GccIceHelper1<T, DependentType>&, U>>
+ GccIce& operator=(GccIceHelper2<U> const&) {}
+};
+
+TEST(OptionalTest, InternalCompilerErrorInGcc5ToGcc10) {
+ GccIce<int> instantiate_ice_with_same_type_as_optional;
+ static_cast<void>(instantiate_ice_with_same_type_as_optional);
+ absl::optional<int> val1;
+ absl::optional<int> val2;
+ val1 = val2;
+}
+
struct Hashable {};
namespace std {