-
Notifications
You must be signed in to change notification settings - Fork 10.4k
GTEST_AMBIGUOUS_ELSE_BLOCKER_ does not block the warning for gcc-7.1. #1119
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
Comments
I ran into this too (with gtest 1.7.0). This may be a bug in GCC.
after preprocessing and it seems pretty clear to me that the else cannot belong to the outside if. |
google/googletest#1119 Let's use the braces till the problem is fixed. No harm in using extra two braces.
google/googletest#1119 Let's use the braces till the problem is fixed. No harm in using extra two braces.
google/googletest#1119 Let's use the braces till the problem is fixed. No harm in using extra two braces.
google/googletest#1119 Let's use the braces till the problem is fixed. No harm in using extra two braces.
Fix some ambiguous else warnings resulting from gtest macros. See google/googletest#1119. Add a missing include that broke compilation on the release build. Make sure to return something from functions, even where there is a DCHECK(false) to prevent compiler warning. Fix alignment of aggregate function intermediate values.
I have been cleaning up older and inactive GitHub googletest issues. You may see an issue "closed" if it appears to be inactive/abandoned |
I tried compiling with GCC7 to see what warnings popped up. Fix some ambiguous else warnings resulting from gtest macros. See google/googletest#1119. Add a missing include that broke compilation on the release build. Fix some warnings that detect missing returns when there is a DCHECK (these warnings already occurred in release builds, but they now happen in gcc7 debug builds). Change-Id: I39a12bc5ed6957c147b7f0dba85c7687cc989439 Reviewed-on: http://gerrit.cloudera.org:8080/12132 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]>
I tried compiling with GCC7 to see what warnings popped up. Fix some ambiguous else warnings resulting from gtest macros. See google/googletest#1119. Add a missing include that broke compilation on the release build. Fix some warnings that detect missing returns when there is a DCHECK (these warnings already occurred in release builds, but they now happen in gcc7 debug builds). Change-Id: I39a12bc5ed6957c147b7f0dba85c7687cc989439 Reviewed-on: http://gerrit.cloudera.org:8080/12132 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]>
google/googletest#1119 Let's use the braces till the problem is fixed. No harm in using extra two braces.
Can we reopen this? This is still affecting users. See all the commits referencing this. Another user ran into this issue in LLVM: |
…ngling-else]' with GCC 7.3 See: google/googletest#1119 llvm-svn: 361862
…ngling-else]' with GCC 7.3 See: google/googletest#1119 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@361862 91177308-0d34-0410-b5e6-96231b3b80d8
Note googletest has disabled this warning internally: #1426 |
with for loops and (where necessary) lambdas. Fixes google#1119. Requires C++11. For example, replace: if (::testing::internal::IsTrue(condition)) ; else GTEST_LOG_(FATAL) << "Condition " #condition " failed. " with: for (bool gtest_check_ = ::testing::internal::IsTrue(condition); \ !gtest_check_; gtest_check_ = true) \ GTEST_LOG_(FATAL) << "Condition " #condition " failed. " This allows the user to continue to stream more information into the violation message, and avoids the "dangling else" warning-error since we aren't using any if/else statements. If the predicate or any branches are more complicated than a single statement-expression, use a lambda; this requires C++11. This is necessary for death, throw, no-throw, and no-fatal-failure tests. Remove the -Werror=dangling-else suppression, since it isn't required any more.
Explicit braces were added to fix the "suggest explicit braces to avoid ambiguous ‘else’" warning since the current solution (switch (0) case 0: default:) doesn't work since gcc 7 (see google/googletest#1119) gcc 13 generates about 5000 of this warning when building libc without this patch.
…7833) Explicit braces were added to fix the "suggest explicit braces to avoid ambiguous ‘else’" warning since the current solution (switch (0) case 0: default:) doesn't work since gcc 7 (see google/googletest#1119) gcc 13 generates about 5000 of these warnings when building libc without this patch.
Starting from gcc 7.1 the GTEST_ASSERT_ and all the dependencies produce the following warning,
when used with if statement without surrounding braces.
It seems GTEST_AMBIGUOUS_ELSE_BLOCKER_ does not do the trick any more.
To reproduce, compile the following code
with
The printout would be
We observe the issue with Google Test 1.8.0, but as far as I can tell, it is the same in the current trunk.
The text was updated successfully, but these errors were encountered: