[llvm-bugs] [Bug 39472] New: Incorrect formatting with new operator and arrays of pointers in C++

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 28 14:14:28 PDT 2018


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

            Bug ID: 39472
           Summary: Incorrect formatting with new operator and arrays of
                    pointers in C++
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hello at schmider.kim
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 21040
  --> https://bugs.llvm.org/attachment.cgi?id=21040&action=edit
Clang Format file

I have discovered a bug with clang-format that seems to interpret the
initialization of a heap-allocated array of pointers with the new operator as a
lambda.

The assignment to x is incorrect, it should look like the assignment to y with
the closing curly brace in the same line.

void somefunc()
{
    x = new a* [] {
        very_long_variable_name_that_causes_a_line_break, nullptr, nullptr,
            nullptr
    };

    y = new b[]{
        another_very_long_variable_name_that_causes_a_line_break, 0, 0, 0, 0};
}

My .clang-format file can be found as an attachment.

-- 
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/20181028/7787a210/attachment.html>


More information about the llvm-bugs mailing list