Skip to content

clang-format-18 AlignArrayOfStructures: Left breaks constructor member initializer list indentation #76803

@MartinsSmirnovs

Description

@MartinsSmirnovs

Given following .clang-format file:

AlignArrayOfStructures: Left
IndentWidth: 4

And following foo.cpp file:

#include <map>

struct Foo {
    explicit Foo()
        : data({
              {1, 2},
          }) {}

    const std::map<int, int> data;
};

I expect that clang-format foo.cpp will not perform formatting, however, it does and sets incorrect indentation of member closing bracket:

#include <map>

struct Foo {
    explicit Foo()
        : data({
              {1, 2},
    }) {}

    const std::map<int, int> data;
};

If AlignArrayOfStructures: Left gets commented out then everything works as expected.

clang-format version:

$ clang-format --version
Ubuntu clang-format version 18.0.0 (++20231208042253+5fc76e6b6da7-1~exp1~20231208042409.1357)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions