| Issue |
52943
|
| Summary |
Incorrect formatting of lambdas inside brace initialisation when the return type has []
|
| Labels |
|
| Assignees |
|
| Reporter |
abt8601
|
Here is a small example that demonstrates the bug:
```cpp
#include <variant>
// Utilities for working with std::variant. Taken from
// https://en.cppreference.com/w/cpp/utility/variant/visit
template <class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
namespace ns {
void foo() {
std::variant<int, double> v;
std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr; }}, v);
}
} // namespace ns
```
After formatting:
```cpp
#include <variant>
// Utilities for working with std::variant. Taken from
// https://en.cppreference.com/w/cpp/utility/variant/visit
template <class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
namespace ns {
void foo() {
std::variant<int, double> v;
std::visit(overloaded{[](auto &&) -> int (*)[] { return nullptr;
}
} // namespace ns
, v);
}
} // namespace ns
```
The bug also appears if the return type is `std::unique_ptr<int[]>`. It does not appear when the return type doesn't have `[]`, e.g. `int *`.
I suspect that it's related to #27146 and #40694, but I'm not certain.
`.clang-format`:
```
BasedOnStyle: LLVM
```
`clang-format --version`:
```
clang-format version 13.0.0 (Fedora 13.0.0-3.fc35)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs