From 679c75f0a67d65f115bb44521f49da3db14c2ad2 Mon Sep 17 00:00:00 2001
From: Vijay Pai <vpai@google.com>
Date: Wed, 15 Jun 2016 13:08:00 -0700
Subject: [PATCH] Deal with issues surrounding const members of classes used in
 containers

---
 test/cpp/end2end/async_end2end_test.cc | 11 +++++++----
 test/cpp/end2end/end2end_test.cc       |  9 ++++++---
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 2e0c9da107..029bdc8bce 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -233,8 +233,11 @@ class TestScenario {
             disable_blocking, credentials_type.c_str(), message_content.size());
   }
   bool disable_blocking;
-  const grpc::string credentials_type;
-  const grpc::string message_content;
+  // Although the below grpc::string's are logically const, we can't declare
+  // them const because of a limitation in the way old compilers (e.g., gcc-4.4)
+  // manage vector insertion using a copy constructor
+  grpc::string credentials_type;
+  grpc::string message_content;
 };
 
 class AsyncEnd2endTest : public ::testing::TestWithParam<TestScenario> {
@@ -1395,9 +1398,9 @@ std::vector<TestScenario> CreateTestScenarios(bool test_disable_blocking,
   for (auto cred = credentials_types.begin(); cred != credentials_types.end();
        ++cred) {
     for (auto msg = messages.begin(); msg != messages.end(); msg++) {
-      scenarios.push_back(TestScenario(false, *cred, *msg));
+      scenarios.emplace_back(false, *cred, *msg);
       if (test_disable_blocking) {
-        scenarios.push_back(TestScenario(true, *cred, *msg));
+        scenarios.emplace_back(true, *cred, *msg);
       }
     }
   }
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 81318866c9..9786350040 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -199,7 +199,10 @@ class TestScenario {
             credentials_type.c_str());
   }
   bool use_proxy;
-  const grpc::string credentials_type;
+  // Although the below grpc::string is logically const, we can't declare
+  // them const because of a limitation in the way old compilers (e.g., gcc-4.4)
+  // manage vector insertion using a copy constructor
+  grpc::string credentials_type;
 };
 
 class End2endTest : public ::testing::TestWithParam<TestScenario> {
@@ -1421,9 +1424,9 @@ std::vector<TestScenario> CreateTestScenarios(bool use_proxy,
   }
   for (auto it = credentials_types.begin(); it != credentials_types.end();
        ++it) {
-    scenarios.push_back(TestScenario(false, *it));
+    scenarios.emplace_back(false, *it);
     if (use_proxy) {
-      scenarios.push_back(TestScenario(true, *it));
+      scenarios.emplace_back(true, *it);
     }
   }
   return scenarios;
-- 
GitLab