https://bugs.llvm.org/show_bug.cgi?id=47545
Bug ID: 47545
Summary: clang-formatter incorrectly breaks the line for
constexpr lambda call initializing a variable
Product: clang
Version: 10.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangb...@nondot.org
Reporter: and...@ethereum.org
CC: djas...@google.com, kli...@google.com,
llvm-bugs@lists.llvm.org
$ clang-format --version
Ubuntu clang-format version
10.0.1-++20200708123514+ef32c611aa2-1~exp1~20200707224111.189
The code that initializes a variable using curly braces and a call to inline
_constexpr_ lambda is formatted incorrectly:
$ echo "int i{[]() constexpr noexcept { std::cout << "hello"; return 1; }()};"
| clang-format
int i{[]() constexpr noexcept {std::cout << hello;
return 1;
}
()
}
;
Removing constexpr specifier results in a valid-looking format:
$ echo "int i{[]() noexcept { std::cout << "hello"; return 1; }()};" |
clang-format
int i{[]() noexcept {
std::cout << hello;
return 1;
}()};
Workaround: adding more parentheses around lambda definition also helps:
$ echo "int i{([]() constexpr noexcept { std::cout << "hello"; return 1;
})()};" | clang-format
int i{([]() constexpr noexcept {
std::cout << hello;
return 1;
})()};
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs