Commit c006f8c1 by zhanyong.wan

fixes a problem caused by gcc 4.6 optimization (by Paul Pluzhnikov)

parent 6a5a25b1
...@@ -662,6 +662,13 @@ ...@@ -662,6 +662,13 @@
# define GTEST_API_ # define GTEST_API_
#endif #endif
#if defined(__GNUC__)
// Ask the compiler to never inline a given function.
#define GTEST_NO_INLINE_ __attribute__((noinline))
#else
#define GTEST_NO_INLINE_
#endif // __GNUC__
namespace testing { namespace testing {
class Message; class Message;
......
...@@ -932,6 +932,11 @@ static int ExecDeathTestChildMain(void* child_arg) { ...@@ -932,6 +932,11 @@ static int ExecDeathTestChildMain(void* child_arg) {
// This could be accomplished more elegantly by a single recursive // This could be accomplished more elegantly by a single recursive
// function, but we want to guard against the unlikely possibility of // function, but we want to guard against the unlikely possibility of
// a smart compiler optimizing the recursion away. // a smart compiler optimizing the recursion away.
//
// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining
// StackLowerThanAddress into StackGrowsDown, which then doesn't give
// correct answer.
bool StackLowerThanAddress(const void* ptr) GTEST_NO_INLINE_;
bool StackLowerThanAddress(const void* ptr) { bool StackLowerThanAddress(const void* ptr) {
int dummy; int dummy;
return &dummy < ptr; return &dummy < ptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment