Bug 122639 - With gcc flag -Werror programs are not compiling using the lib
Summary: With gcc flag -Werror programs are not compiling using the lib
Status: RESOLVED FIXED
Alias: None
Product: cppunit
Classification: Unclassified
Component: General (show other bugs)
Version:
(earliest affected)
1.14
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-10 15:59 UTC by groll
Modified: 2019-02-14 14:42 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Added some brackets to make it more clear for the compile which things belongs to the if body (1.21 KB, patch)
2019-01-10 16:05 UTC, groll
Details

Note You need to log in before you can comment on or make changes to this bug.
Description groll 2019-01-10 15:59:24 UTC
If I use -Werror for compiling my program which uses cppunit it is not compiling.
The error is:
error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
...
 note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’

This is because of line 520 and following in TestAssert.h:
 if ( cpputCorrectExceptionThrown_ )                                     \
	     break;                                                      \
 CPPUNIT_NS::Asserter::fail( cpputMsg_,                                  \
                                  CPPUNIT_SOURCELINE() );                \

Here everything will be in one line for the compiler because of the macro implementation and only the break is inside of the if body and not the following stuff but it seems like the following has also to be in the if body.
This can be fixed with easy adding some brackets:

 if ( cpputCorrectExceptionThrown_ )                                     \
	   {  break; }                                                   \
 CPPUNIT_NS::Asserter::fail( cpputMsg_,                                  \
                                  CPPUNIT_SOURCELINE() );                \
Comment 1 groll 2019-01-10 16:05:07 UTC
Created attachment 148224 [details]
Added some brackets to make it more clear for the compile which things belongs to the if body
Comment 2 Xisco Faulí 2019-02-12 17:03:55 UTC
@Markus, @Stephan Bergmann, any opinion here ?
Comment 3 Markus Mohrhard 2019-02-14 14:42:37 UTC
Thanks Tobias. The patch has been added to the upstream repository as https://cgit.freedesktop.org/libreoffice/cppunit/commit/?id=51efd6f2184405dea29265ea0dd25c71b348404a