| Issue |
169975
|
| Summary |
[clang] c23 auto doesn't work with gnu's cleanup attribute
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
xcpky
|
```c
#include <stdlib.h>
struct box_int {
int *vp;
};
struct box_int box_int_new(int v)
{
int *vp = malloc(sizeof(int));
*vp = v;
return (struct box_int) {
.vp = vp,
};
}
void box_int_free(struct box_int *b)
{
free(b->vp);
}
int main()
{
[[gnu::cleanup(box_int_free)]]
auto b = box_int_new(99);
return *b.vp;
}
```
gcc compiles fine.
clang21 with -std=gnu23 doesn't compile, error message:
```
a.c:24:17: error: 'cleanup' function 'box_int_free' parameter has type 'struct box_int *' which is incompatible
with type 'auto *'
24 | [[gnu::cleanup(box_int_free)]]
| ^
1 error generated.
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs