Skip to content

[clang-tidy] readability-redundant-parentheses conflicts with suggested -Wunreachable-code mitigation #162899

@firewave

Description

@firewave
void f(bool b)
{
    if (false && b) {}
}

The code above will report the following:

<source>:3:18: warning: code will never be executed [-Wunreachable-code]
    3 |     if (false && b) {}
      |                  ^
<source>:3:9: note: silence by adding parentheses to mark code as explicitly dead
    3 |     if (false && b) {}
      |         ^
      |         /* DISABLES CODE */ ( )

But addressing that as suggested will lead to a clang-tidy warning:

<source>:3:9: warning: redundant parentheses around expression [readability-redundant-parentheses]
    3 |     if ((false) && b) {}
      |         ^     ~

https://godbolt.org/z/nTvEGrr7c

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions