llvm / llvm/llvm-project

[clang-tidy] False-positive result of check readability-redundant-parentheses with rvalue overload

Open
#192,435 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/bME79eef6):
```c++
#include
#include

std::string getString()
{
return (std::ostringstream{} << "Hello World").str(); // <-- this line triggers the warning
}

int main()
{
std::cout << getString() << '\n';
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 by reproducing the warning with the C++ example and Godbolt link, then inspect the clang-tidy readability-redundant-parentheses check. Done means the shown rvalue-overload expression no longer produces a false positive and a regression test covers the case.

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.