llvm / llvm/llvm-project

[clang-tidy] False-positive result of check readability-redundant-parentheses with an iterator

Open
#192,438 1 comment 0 reactions 0 assignees View on GitHub
clang-tidy false-positive
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This code triggers a false-positive result from clang-tidy check readability-redundant-parentheses (see https://godbolt.org/z/zYrfcxo69):
```c++
#include
#include
#include

struct S
{
int getValue() const { return 0; }
};

int main()
{
std::vector> v;
v.push_back(std::make_shared());

std::vector>::const_iterator it = v.cbegin();
std::cout << (*it)->getValue() << std::endl; // <-- this line triggers the warning

return 0;
}
```
The issue occurs on the main branch (upcoming clang 23). In clang 22 there was no such warning.

Contributor guide

Open the contributing guide

Research direction

Start with the minimal C++ reproducer and the clang-tidy readability-redundant-parentheses check, using the linked Godbolt example to compare clang 22 with the main branch. Trace why the (*it)->getValue() expression is diagnosed; done means the valid expression is no longer reported while other redundant-parentheses cases remain covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.