-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorbugzillaIssues migrated from bugzillaIssues migrated from bugzillaclang-formatconfirmedVerified by a second partyVerified by a second partyinvalid-code-generationTool (e.g. clang-format) produced invalid code that no longer compilesTool (e.g. clang-format) produced invalid code that no longer compiles
Description
Bugzilla Link | 44947 |
Version | 9.0 |
OS | Linux |
CC | @w-m,@mydeveloperday |
Extended Description
The following code
int foo {[]() {
int bar{ 0 };
return 0;
}()};
is formatted into
int foo{ []() {
intbar{ 0 };
return 0;
}() };
by clang-format-9 when using -style="{AlignConsecutiveDeclarations: true, Cpp11BracedListStyle: false}".
The resulting code no longer compiles - note the missing space between int
and the variable name.
Changing either formatting option will fix the problem, it's the combination that leads to the erroneous output.
The code is also correctly formatted if the outer braces (initialization of foo) are replaced by a =
assignment.
I don't have a later clang-format version than 9 installed locally, but trying this code snippet in https://zed0.co.uk/clang-format-configurator with 10.0.0+b452de0 and these two formatting options, the output suddenly gets blank (-> crash?).
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorbugzillaIssues migrated from bugzillaIssues migrated from bugzillaclang-formatconfirmedVerified by a second partyVerified by a second partyinvalid-code-generationTool (e.g. clang-format) produced invalid code that no longer compilesTool (e.g. clang-format) produced invalid code that no longer compiles