Skip to content

[clang-format] AlignArrayOfStructures crashes with trailing comment #55493

Closed
llvm/llvm-project-release-prs
#784
@timblechmann

Description

@timblechmann

my clang-format file contains:

AlignArrayOfStructures: Left

running clang-format crashes with:

/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x31)[0x7ff69a14af31]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0xee)[0x7ff69a148c6e]
/lib/x86_64-linux-gnu/libLLVM-14.so.1(+0xe40466)[0x7ff69a14b466]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7ff698df2520]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x2c74deb)[0x7ff6a2851deb]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format17WhitespaceManager35alignArrayInitializersLeftJustifiedEONS1_16CellDescriptionsE+0xe7)[0x7ff6a28517e7]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format17WhitespaceManager22alignArrayInitializersEjj+0x76)[0x7ff6a28502b6]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format17WhitespaceManager20generateReplacementsEv+0x176)[0x7ff6a284d246]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x2c1dbad)[0x7ff6a27fabad]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format13TokenAnalyzer7processEv+0x376)[0x7ff6a2823246]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(+0x2c2aa71)[0x7ff6a2807a71]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format8internal8reformatERKNS0_11FormatStyleEN4llvm9StringRefENS5_8ArrayRefINS_7tooling5RangeEEEjjjS6_PNS0_23FormattingAttemptStatusE+0x8db)[0x7ff6a27f2aeb]
/lib/x86_64-linux-gnu/libclang-cpp.so.14(_ZN5clang6format8reformatERKNS0_11FormatStyleEN4llvm9StringRefENS4_8ArrayRefINS_7tooling5RangeEEES5_PNS0_23FormattingAttemptStatusE+0x51)[0x7ff6a27f38c1]
clang-format-14[0x40b129]
clang-format-14[0x409335]
/lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x7ff698dd9d90]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7ff698dd9e40]
clang-format-14[0x406475]

the code in question is:

std::array<pairs> foo()
{
    return { {
        { a, d },
        { b, e },
        { c, f }, // crash
    } };
}

removing the railing comment, the crash goes away:

std::array<pairs> foo()
{
    return { {
        { a, d },
        { b, e },
        { c, f },
    } };
}

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions