okere-prince / googlemock

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

-D_GLIBCXX_DEBUG=1 introduces bugs #92

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. On Linux, compile the attached program with no specific flags to g++
2. Run it, it passes.
3. Compile again, now with -D_GLIBCXX_DEBUG=1
4. Run again. It fails.

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

Same output in 2 and 4.

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

gmock 1.4.0. on Gentoo amd64 with g++-4.3.4 and Ubuntu 9.10 (karmik) with
g++-4.4.1.

Please provide any additional information below.

Original issue reported on code.google.com by bjor...@fahller.se on 20 Dec 2009 at 2:39

Attachments:

GoogleCodeExporter commented 9 years ago
Your iface class needs to have a virtual destructor, as mentioned in the 
googlemock wiki.

Please provide the error messages you see in step 4.

Original comment by w...@google.com on 21 Dec 2009 at 7:11

GoogleCodeExporter commented 9 years ago
The virtuality of the destructor is irrelevant to this case, and adding it 
changes
nothing.

Attached are the outputs from running (changed to include the virtual 
destructor,)
compiled both with and without -D_GLIBCXX_DEBUG, and also the result from a 
valgrind
run with -D_GLIBCXX_DEUBUG (it's not pretty!)

Original comment by bjor...@fahller.se on 22 Dec 2009 at 8:43

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by w...@google.com on 22 Dec 2009 at 5:45

GoogleCodeExporter commented 9 years ago
You need to call InitGoogleMock instead of InitGoogleTest.  See
http://code.google.com/p/googlemock/wiki/ForDummies .  Otherwise gtest is 
initialized
but gmock is not.

gmock should fail with an explicit message though.  I'll create an issue to 
track it.

Original comment by w...@google.com on 22 Dec 2009 at 8:47

GoogleCodeExporter commented 9 years ago
Please see issue 93.

Original comment by w...@google.com on 22 Dec 2009 at 8:49

GoogleCodeExporter commented 9 years ago
I'm closing this issue now.  Please reopen it if InitGoogleMock doesn't fix the 
problem.

Original comment by w...@google.com on 23 Dec 2009 at 2:50

GoogleCodeExporter commented 9 years ago
You had my hopes up, but alas, it fails the same way.

Original comment by bjor...@fahller.se on 23 Dec 2009 at 4:17

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by w...@google.com on 23 Dec 2009 at 6:36

GoogleCodeExporter commented 9 years ago
Did you compile gmock itself with -D_GLIBCXX_DEBUG=1 too?  You need to define 
this
macro when compiling both gmock and t.cpp, otherwise you get undefined behavior 
for
violating the one-definition rule of C++.

On my Ubunto machine, I got:

- compiling both gmock and t.cpp without -D_GLIBCXX_DEBUG=1 => works fine.
- compiling both gmock and t.cpp with -D_GLIBCXX_DEBUG=1 => works fine.
- compiling gmock without -D_GLIBCXX_DEBUG=1 but compiling t.cpp with it => 
segfault.

Closing the issue now.  Please reopen if this doesn't fix your problem.

Original comment by w...@google.com on 23 Dec 2009 at 5:43