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

g++ -Wparentheses warnings #593

Closed
vadz opened this issue Feb 22, 2016 · 6 comments
Closed

g++ -Wparentheses warnings #593

vadz opened this issue Feb 22, 2016 · 6 comments

Comments

@vadz
Copy link
Contributor

vadz commented Feb 22, 2016

This has been discussed/mentioned in many different places, but the issues/PRs have all been closed while the problem still exists, so I'd like to open a new one if only to monitor it.

The problem is that using CATCH( x == y ) results in a

warning: suggest parentheses around comparison in operand of '==' [-Wparentheses]

when compiling with -Wall since the changes of #247. This is very annoying (each full warning takes 6 lines, but even would have been too much considering the number of them I'm getting).

The worst part is that there doesn't seem to be any way to get rid of it without disabling the warning globally in catch.hpp, i.e. disabling it temporarily and restoring it doesn't work. And, contrary to what I wrote myself in #528, this is not limited to older g++ versions but also happens with g++ 5.3, for example.

Something really needs to be done about this and the simplest solution is to indeed disable the warning. But while I'm ambivalent about this warning myself (it didn't find a single real problem in my code but created many thousands false positives, since it was introduced), I think it's bad manners for a library to disable warnings that the user didn't disable explicitly, so it would be nice to find another solution. Unfortunately the only one I see is reverting #247. Maybe I'm missing something, but I just don't see many benefits in this change, writing CATCH( 1+1 == 2 ) is not something I often (or ever, in fact) do, and it could have been done using CATCH( (1+1) == 2 ) even before, without any real loss of functionality.

TL;DR: Currently the first thing I do when upgrading CATCH in any of the projects using it is to disable -Wparentheses and it's tiresome to keep doing it. This warning should be either disabled in CATCH itself or #247 should be reverted.

philsquared added a commit that referenced this issue Feb 29, 2016
- should address #593, #528, #521, #496 (and possibly others)
philsquared added a commit that referenced this issue Jun 7, 2016
- should address #593, #528, #521, #496 (and possibly others)
@obfuscated
Copy link

Just tried the latest version of Catch and stumbled on this issue. The new version is unusable and I want to upgrade to minimize the number of warnings emitted by Catch. :)
Forcing users to disable -Wparentheses is not good user experience in every project.
I'm using GCC 4.4 if it makes a difference.

@janisozaur
Copy link
Contributor

janisozaur commented Dec 12, 2016

For what it's worth: you can work your way around it by putting catch in its own "namespace" directory and include it with -isystem rather than -I, which will silence warnings on headers included from this location.

See https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html

@obfuscated
Copy link

@janisozaur I've just tried it and it doesn't help. Unfortunately these warnings aren't generated by the catch headers, but by the code injected by the macros from the catch headers.

@philsquared
Copy link
Collaborator

(catching up here)
@obfuscated and @janisozaur: are you saying that the commit (cited above) on 29th feb doesn't fix it for you?

@obfuscated
Copy link

@philsquared Yep, I'm testing 2be3727 which contains the mentioned fix (91bfe68) and the error is still there.

@horenmar
Copy link
Member

I am going to close this, since its a duplicate of #674, which was (hopefully) resolved.

If it isn't, please reopen that one.

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

5 participants