[llvm-bugs] [Bug 44947] New: Spaces between type and variable name in IIFE lambda in brace init removed by formatter

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Feb 18 07:15:21 PST 2020


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: unassignedclangbugs at nondot.org
          Reporter: llvm at morgenst.de
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200218/188b787d/attachment.html>


More information about the llvm-bugs mailing list