Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHECK / REQUIRE (true==true) fails in Debug Build #50

Closed
trenki2 opened this issue Sep 18, 2011 · 5 comments
Closed

CHECK / REQUIRE (true==true) fails in Debug Build #50

trenki2 opened this issue Sep 18, 2011 · 5 comments

Comments

@trenki2
Copy link

trenki2 commented Sep 18, 2011

I had code like this and somehow in Debug Build my tests failed:

REQUIRE(task->isTerminated() == false);
REQUIRE(task->isRunning() == false);
REQUIRE(task->execStatus() == Task::Created);

The following tests the scenario just with true and false statements.

#include "catch_with_main.hpp"

ANON_TEST_CASE()
{
    CHECK(false == false); // Fails in Debug!!!
    CHECK(true == true);   // Fails in Debug!!!

    // Extra parenthesis make it work!
    CHECK((false == false));
    CHECK((true == true));

    CHECK_FALSE(false == true);
    CHECK_FALSE(true == false);

    // Extra parenthesis make it fail!
    CHECK_FALSE((false == true)); // Fails in Debug!!!
    CHECK_FALSE((true == false)); // Fails in Debug!!!
}
@philsquared
Copy link
Collaborator

That's really bizarre.
AFAICS it only does this for the latest version, in MSVC++, in debug mode.

But I think I have found the cause (but have run out of time to fix it this morning - will have to do that this evening).

I recently added an overload for expression components that are bools that take the bool by value instead of by const ref. This was to prevent a case where expressions with undefined types were being evaluated when they didn't need to be.

However, that (now local value) bool is being held between calls by const ref - so it's now referencing an out-of-scope value!

It's amazing (and unfortunate) it's taken so long to show, but such is the nature of these things. My apologies to the community for letting such a schoolboy error slip through.

Will have it fixed as soon as possible.

@philsquared
Copy link
Collaborator

I've checked in my "fix". However I won't have access to VC++ again until tomorrow so I've only been able to verify that it doesn't break on my gcc/ XCode set-up.
If anyone has a chance to verify with VC++ before I do please let us know here.

@trenki2
Copy link
Author

trenki2 commented Sep 20, 2011

I just tested the updated CATCH version with the test cases that I provided above and they now succeed in Release and Debug mode for VC++ 2008 Express!

@trenki2 trenki2 closed this as completed Sep 20, 2011
@philsquared
Copy link
Collaborator

Thanks @trenki2.

I've just been able to verify it in VS2008 too.
Although there seems to be a bug in GitHub at the moment where every time I try to upload a new version of the single_include header as a separate download it reverts to the previous version!
I presume you were using the repos version?

@trenki2
Copy link
Author

trenki2 commented Sep 20, 2011

Yes, I simply downloaded the new zip archive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants