llvm / llvm/llvm-project

[clang] Redundant error message for `auto*` in structured binding

Open
#222,605 1 comment 0 reactions 0 assignees View on GitHub
clang:diagnostics
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c++
struct S {
int *p, *q;
};

void f(S s) {
auto* [x, y] = s;
}
```
```
:10:11: error: structured binding declaration cannot be declared with type 'auto *'; declared type must be 'auto' or reference to 'auto'
10 | auto* [x, y] = s;
| ^
:10:11: error: variable '' with type 'auto *' has incompatible initializer of type 'S'
10 | auto* [x, y] = s;
| ^ ~
```
The second error seem unhelpful and redundant.
https://godbolt.org/z/54h3jq6Eo

Contributor guide

Open the contributing guide

Research direction

Start by compiling the provided reduced C++ example with Clang and inspect the structured-binding semantic diagnostic path. Confirm the redundant incompatible-initializer error is emitted after the invalid `auto*` type diagnostic, then add or update coverage so the example reports only the useful error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.