https://bugs.llvm.org/show_bug.cgi?id=44947

            Bug ID: 44947
           Summary: Spaces between type and variable name in IIFE lambda
                    in brace init removed by formatter
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

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?).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to