Skip to content

[clang] the "cleanup" attribute prevents type deductionΒ #129631

@shynur

Description

@shynur
/* a.cpp */
int open() { return 0; }
void close(decltype(open()) *) {}
int main() {
  auto fd [[gnu::cleanup(close)]] = open();
}
$ clang-21 a.cpp
a.cpp:4:26: error: 'cleanup' function 'close' parameter has type 'decltype(open()) *' (aka 'int *') which is incompatible with type 'auto *'
    4 |   auto fd [[gnu::cleanup(close)]] = open();
      |                          ^
1 error generated.

I built Clang in the main branch when its HEAD is commit cb7030dbe7f3f1947c31b3059958ff3968cc22ff

Metadata

Metadata

Assignees

No one assigned

    Labels

    c23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions