-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Warning for parentheses around comparison in operand of ‘==’ #870
Comments
We are currently attempting to suppress the warning by using This would let us suppress it only for the assertion macros, but as it turns out, GCC likely has a long-standing bug in handling #include <stdio.h>
#define TEST(expr) \
int a = 1; \
_Pragma( "GCC diagnostic push" ) \
_Pragma( "GCC diagnostic ignored \"-Wparentheses\"" ) \
if (a <= expr) { \
printf("filler\n"); \
} \
_Pragma( "GCC diagnostic pop" )
int main(){
int b = 2, c = 3;
TEST(b == c);
} If you compile this using current GCC as C, it will not trigger the warning. If you compile this as C++, it will warn about bad parentheses. We will likely end-up using plain pragma to suppress the warning globally in the next release. |
I have the same experience in doctest with
It's weird that I don't get the |
Same for me (GCC 5.2). In my case, (there were also a few of these spurious warnings with 1.7.2 version that I had to wrap in parens manually -- I couldn't figure out the logic behind those) |
Related: #565 |
@aldanor Basically, at some point in the past (can't tell you version on top of my head, but a recent one), we switched to using We will probably end up just using |
I am going to close this, as I moved Catch back to force disabling This means that we disable the warning for GCC users even outside our assertions, but the spotty |
I know this was reported many times and maybe fixed (at least for gcc 4.7) but I'm gaving this issue with GCC 6.3 on Linux Mint 18.
Anyway a temporary solution that works for me is to add
#pragma GCC diagnostic ignored "-Wparentheses"
in the source code
The text was updated successfully, but these errors were encountered: