-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Fix parentheses warning with Catch #1067
Conversation
Since _Pragma is less buggy in clang. Don't what other compiler says..
One more note: the problem here is that we are deviating from the Catch master (in addition to the template test cases) and I don't know what solution will be chosen in Catch. |
Thanks a lot for this PR (and the very informative description). |
Conflicts: ChangeLog.md
Done ;) |
Perfect, thanks. |
Fix parentheses warning with Catch
Huh ... if not too late, could you reopen this PR ? I have some warnings back :/ |
mmm... let's try a revert.. |
ok crap. |
Thanks but I don't know what to do since Finally, maybe the best choice is
|
Can you please reopen the PR? I'll test what's happening on my os. |
Done: #1069 |
Following the discussion in #1060, this PR proposes a solution to avoid warnings about missing parentheses in Catch assertions when using gcc (up to 4.7 but following versions may be concerned too).
Until now, the solution was to add extra parentheses around expression like this:
As the assertion failed, Catch outputs:
but one of the main argument of Catch is his ability to expand expressions. For example, without extra parentheses:
Catch outputs:
This issue has been addressed many times in Catch project ( see catchorg/Catch2#528, catchorg/Catch2#521 and catchorg/Catch2#247 ) and the solutions proposed so far are:
-Wparentheses
, at least when usinggcc
,<=
operator ofResultBuilder
by an operator with a slightly greater priority, like<<
or>>
.The remarks about those solutions are:
-Wall
seems to be enable in DGtal only whenBUILD_TESTING
is set (see https://github.com/DGtal-team/DGtal/blob/master/cmake/CpackCtest.cmake )._Pragma
to tell gcc to disable the warnings:Unfortunately, there is many bugs with
_Pragam
andgcc
that make it useless here.3. Reverting catchorg/Catch2#247 implies that expressions like
REQUIRE( 1+2 == 3 )
do not compile anymore (extra parentheses are then needed around1+2
).4. Using
>>
instead of<=
removes warnings with gcc but clang wakes up with-Woverloaded-shift-op-parentheses
warning ...Fortunately,
_Pragma
works fine with clang and it enables us to clean the warns.This pull request is about that last solution. I don't know if other compilers (clang on Mac, icc, visual studio, ...) are ok with that PR.