llvm / llvm/llvm-project

readability-trailing-comma - false positive + default function argument

Open
#223,646 1 comment 0 reactions 1 assignee Assigned to @vbvictor View on GitHub
clang-tidy false-positive
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

LLVM version 23.1.1

`clang-tidy --checks='-*,readability-trailing-comma' test.cpp -- -std=c++26`

Reproducer:

```c++
struct Options
{
int option1{};
int option2{};
};

class Class
{
public:
static void setOptions(Options opts1 = {}, Options opts2 = {})
{
(void)opts1;
(void)opts2;
}

private:
};

```

Output:

```
test.cpp:11:46: error: initializer list should not have a trailing comma [readability-trailing-comma,-warnings-as-errors]
11 | static void setOptions(Options opts1 = {}, Options opts2 = {})
| ^
```

Contributor guide

Open the contributing guide

Research direction

Start by running the clang-tidy command against the supplied test.cpp reproducer with C++26 enabled, then trace the readability-trailing-comma check that reports the default arguments. Done means the valid empty initializer lists in default function arguments no longer produce a diagnostic, while genuine trailing-comma 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
Active
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.