catchorg / catchorg/Catch2

Catch2 should not trigger `-Werror=parentheses` by default

Open
#2,654 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

**Describe the bug**
Catch2 triggers`-Werror=parentheses` on linux (gcc 9.3.1). Here is the error message:

```
_deps/catch2-src/src/catch2/internal/catch_test_macro_impl.hpp:57:67: error: suggest parentheses around comparison in operand of ‘==’ [-Werror=parentheses]
57 | catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \
_deps/catch2-src/src/catch2/catch_test_macros.hpp:125:26: note: in expansion of macro ‘INTERNAL_CATCH_TEST’
125 | #define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ )
| ^~~~~~~~~~~~~~~~~~~
```

**Expected behavior**
No warning should be produced.

**Reproduction steps**
Any `REQUIRE(x == y)` will do.

**Platform information:**

- OS: Centos Linux 7
- Compiler+version: **GCC v9.3.1**
- Catch version: **v3.3.2**

**Additional context**
This is related to https://github.com/catchorg/Catch2/issues/674, which is closed but not fixed.

Contributor guide

Open the contributing guide

Research direction

Reproduce the warning with GCC 9.3.1 using any REQUIRE(x == y) case, then inspect src/catch2/internal/catch_test_macro_impl.hpp and src/catch2/catch_test_macros.hpp, especially the macro expansion shown in the report. Done means the same reproduction no longer triggers -Werror=parentheses by default.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.