xinguai / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Using death test asserts needs RE::RE(const testing::internal::RE&) copy constructor #172

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile any test case using death test asserts (eq. EXPECT_EXIT())

What is the expected output? What do you see instead?

The following error occurs:

"Example_unittest.cpp", line 14: Error: testing::internal::RE::RE(const 
testing::internal::RE&) is not accessible from 
jagent::ContextHelpTest_HelpDeathTest_Test::TestBody().
"Example_unittest.cpp", line 14: Warning (Anachronism): 
testing::internal::RE::RE(const testing::internal::RE&) is not accessible 
from jagent::ContextHelpTest_HelpDeathTest_Test::TestBody().

What version of the product are you using? On what operating system?

gtest 1.3.0

uname -a
SunOS 5.10 Generic_118833-03 sun4u sparc SUNW,Sun-Fire-V890

CC -V
Sun C++ 5.8 2005/10/13

Please provide any additional information below.

For some reasons the Sun compiler needs the copy constructor for the "const 
::testing::internal::RE& gtest_regex = (regex);" assignment.

The following patch solves this problem:

==== gtest-1.3.0/include/gtest/internal/gtest-death-test-internal.h#1 - 
gtest-1.3.0/include/gtest/internal/gtest-death-test-internal.h ====
@@ -158,7 +158,7 @@
 #define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \
   GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
   if (true) { \
-    const ::testing::internal::RE& gtest_regex = (regex); \
+    const ::testing::internal::RE gtest_regex(regex); \
     ::testing::internal::DeathTest* gtest_dt; \
     if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, 
\
         __FILE__, __LINE__, &gtest_dt)) { \

Original issue reported on code.google.com by ade...@gmail.com on 29 Jul 2009 at 2:45

GoogleCodeExporter commented 9 years ago

Original comment by zhanyong...@gmail.com on 16 Sep 2009 at 6:06

GoogleCodeExporter commented 9 years ago

Original comment by w...@google.com on 23 Mar 2010 at 7:27