[clang] crashes with format_matches attribute after invalid declaration
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Reproducer:
https://godbolt.org/z/336x7roqh
```c
int bar(char *) __attribute__((format_matches(printf, 1, "%s")));
void foo() {
const *const fmt2 = fmt;
bar(fmt2);
}
```
Output:
```console
:4:16: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
4 | const *const fmt2 = fmt;
| ~~~~~ ^
| int
:4:23: error: use of undeclared identifier 'fmt'; did you mean 'fmt2'?
4 | const *const fmt2 = fmt;
| ^~~
| fmt2
:4:16: note: 'fmt2' declared here
4 | const *const fmt2 = fmt;
| ^
:5:7: error: incompatible pointer types passing 'const int *const' to parameter of type 'char *' [-Wincompatible-pointer-types]
5 | bar(fmt2);
| ^~~~
:1:15: note: passing argument to parameter here
1 | int bar(char *) __attribute__((format_matches(printf, 1, "%s")));
| ^
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
Contributor guide
Research direction
Start with the Godbolt reproducer and the shown C source, then run the same declaration and invalid use through Clang to confirm the crash. Trace the format_matches attribute handling after the invalid declaration; done means the diagnostics remain valid and compilation no longer terminates with SIGSEGV.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100