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ang-format] Segfault with `clang-format` when using `AlignArrayOfStructures`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
therufuser
</td>
</tr>
</table>
<pre>
Hey there :)
I'm working on my `.clang-format`-config for a project ATM and was trying to see what effect setting `AlignArrayOfStructures` to anything other than `None`.
It appears to me that I have hit some weird edge case?
### Working example
Consider this input file:
```
// Working example of a struct-array
struct vertex {
float position[3];
float color[4];
float normal[3];
};
struct vertex vertices[1] = {
{
{ 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0 }
},
};
```
This compiles fine with `g++ -c bug.cpp` and `clang-format --style=file --verbose bug.cpp` gives the following output:
```
Formatting bug.cpp
struct vertex {
float position[3];
float color[4];
float normal[3];
};
struct vertex vertices[1] = {
{{ 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0 }},
};
```
### Broken example
Now consider this input. Notice that I've only added a single comma inside the struct-initializer. I believe this to be perfectly fine syntax since I use it all over the place and my compiler never complains:
```
// Non-working example of a struct-array
struct vertex {
float position[3];
float color[4];
float normal[3];
};
struct vertex vertices[1] = {
{
{ 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0 },
},
};
```
Like I said, `g++ -c bug.cpp` is perfectly happy compiling this for me. Now when I run this through `clang-format --style=file --verbose bug.cpp` I get something that's definitely not the expected output ^^:
```
Formatting bug.cpp
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Program arguments: clang-format --style=file --verbose bug.cpp
#0 0x00007f2f1885dc93 (/usr/bin/../lib/libLLVM-13.so+0xba2c93)
#1 0x00007f2f1885b4a6 (/usr/bin/../lib/libLLVM-13.so+0xba04a6)
#2 0x00007f2f17915da0 __restore_rt sigaction.c:0:0
#3 0x00007f2f214dcf48 clang::format::WhitespaceManager::alignArrayInitializersLeftJustified(clang::format::WhitespaceManager::CellDescriptions&&) (/usr/bin/../lib/libclang-cpp.so.13+0x2ff3f48)
#4 0x00007f2f214ddf23 clang::format::WhitespaceManager::alignArrayInitializers(unsigned int, unsigned int) (/usr/bin/../lib/libclang-cpp.so.13+0x2ff4f23)
#5 0x00007f2f214e2d5d clang::format::WhitespaceManager::generateReplacements() (/usr/bin/../lib/libclang-cpp.so.13+0x2ff9d5d)
#6 0x00007f2f2146ce4f (/usr/bin/../lib/libclang-cpp.so.13+0x2f83e4f)
#7 0x00007f2f214a13e9 clang::format::TokenAnalyzer::process() (/usr/bin/../lib/libclang-cpp.so.13+0x2fb83e9)
#8 0x00007f2f2146c3a6 (/usr/bin/../lib/libclang-cpp.so.13+0x2f833a6)
#9 0x00007f2f2146c578 (/usr/bin/../lib/libclang-cpp.so.13+0x2f83578)
#10 0x00007f2f2146f94a clang::format::internal::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, unsigned int, unsigned int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus*) (/usr/bin/../lib/libclang-cpp.so.13+0x2f8694a)
#11 0x00007f2f2147062d clang::format::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, llvm::StringRef, clang::format::FormattingAttemptStatus*) (/usr/bin/../lib/libclang-cpp.so.13+0x2f8762d)
#12 0x000055dbbcfa8362 (/usr/bin/clang-format+0xf362)
#13 0x000055dbbcfa1f40 (/usr/bin/clang-format+0x8f40)
#14 0x00007f2f17900b25 __libc_start_main (/usr/bin/../lib/libc.so.6+0x27b25)
#15 0x000055dbbcfa21de (/usr/bin/clang-format+0x91de)
zsh: segmentation fault (core dumped) clang-format --style=file --verbose bug.cpp
```
Like I said previously: This happens with any value other than `None` - so either `Left` or `Right` breaks it for me.
### Additional Info
Since it told me to file a bug that is what I'm doing right now.
I'm running Arch-Linux on this ThinkPad T450s:
```
$ uname -a
Linux $(hostname) 5.16.2-arch1-1 #1 SMP PREEMPT Thu, 20 Jan 2022 16:18:29 +0000 x86_64 GNU/Linux
```
Here is some info about my `clang`-setup:
```
$ clang-format --version
clang-format version 13.0.0
$ ldd `which clang-format`
linux-vdso.so.1 (0x00007ffcb635f000)
libclang-cpp.so.13 => /usr/bin/../lib/libclang-cpp.so.13 (0x00007f8ce3e90000)
libLLVM-13.so => /usr/bin/../lib/libLLVM-13.so (0x00007f8cdd662000)
libstdc++.so.6 => /usr/bin/../lib/libstdc++.so.6 (0x00007f8cdd44c000)
libc.so.6 => /usr/bin/../lib/libc.so.6 (0x00007f8cdd280000)
libpthread.so.0 => /usr/bin/../lib/../lib/libpthread.so.0 (0x00007f8cdd25f000)
libm.so.6 => /usr/bin/../lib/../lib/libm.so.6 (0x00007f8cdd11b000)
libgcc_s.so.1 => /usr/bin/../lib/../lib/libgcc_s.so.1 (0x00007f8cdd0fe000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f8ce7a00000)
libffi.so.8 => /usr/bin/../lib/../lib/libffi.so.8 (0x00007f8cdd0f2000)
libedit.so.0 => /usr/bin/../lib/../lib/libedit.so.0 (0x00007f8cdd0b7000)
libdl.so.2 => /usr/bin/../lib/../lib/libdl.so.2 (0x00007f8cdd0b0000)
libz.so.1 => /usr/bin/../lib/../lib/libz.so.1 (0x00007f8cdd096000)
libncursesw.so.6 => /usr/bin/../lib/../lib/libncursesw.so.6 (0x00007f8cdd023000)
libxml2.so.2 => /usr/bin/../lib/../lib/libxml2.so.2 (0x00007f8cdce97000)
libicuuc.so.70 => /usr/bin/../lib/../lib/libicuuc.so.70 (0x00007f8cdcc9b000)
liblzma.so.5 => /usr/bin/../lib/../lib/liblzma.so.5 (0x00007f8cdcc72000)
libicudata.so.70 => /usr/bin/../lib/../lib/libicudata.so.70 (0x00007f8cdb056000)
```
And my `.clang-format` (which I had to rename for uploading here): [.clang-format](https://github.com/llvm/llvm-project/files/7945400/default.clang-format.txt)
I really hope this information is useful to you! I couldn't find any report-template so I'm just winging it here...
// I also really hope this isn't something obvious like `gcc` being more permissive when really this is broken syntax.
// Either way, I suppose, `clang-format` should be handling this more gracefully :D
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWUlv6zgS_jXOhbCh3dYhB2ebTiN5EySZ6WNASdTSoUSBpOI4v36qKDkxZWexpw89wDz4OabI2j8Wi6VEZOvT39ia6JJJRib-cuLFE-di4iz77-uJN6_JSsjnqimIaEi9JpPImaWcNsU0F7KmGsbTVDR5VRB4QChppfiTpZosH28JbTKyoopouUYOWhDFGFmVVBOW57hKMa1xCtgseVU0Synp-p_5g5ZdqjvJFEwgHW3WujRaoLKgMW2Q5pdoGGpkaa0JbVtGpULCmuFiTa5JSV8YKSuQKeDhilUyIywrGEmpYhP_apvHxPP7D_ljsJ690rrlrJ8-F42qMqNHpUjVtJ0meQWz_oY-cobPwO4KPmNeROTgL2VMnVI0fFuF_jl5YVKzVzKZn20m45wLMKgVqtKVaCbhmT8JLyb-eEEquJAwG-ydbTB6fId4vr10Vw38U6UQlfDMBTrAzIWlmvXbDIkz8c6HL4Ls4cfo8Vdz5vEHd1yyR1Pb248YlFTULUREQVwaiHalS8RLMfHO4EOmKUm6Ypa2LeILYQp_t2FNplOl1xjRCwwsDMH0RCi2TVdULyAAAAnQ51ysDD47DWj4DAhXhrlB_IbP_3aw_5oA_yyu4615JsUza-yd-UuswBc7u3NGfgm0ZcgFkNcgF4iGrwnNMpbhNoSYQJwBNjUFGmRgIjtsz6oB_1NevTE5g1ySMF6xF9ZLgCyTMNIyiRkNWBrEqXWj6SuyBanXpAPkQOqhnBPxYlQDCk5hDsEHeXXAqyQNw3kccgp6fJNSIAFOV_9PK0eh7h1yP84sN9UzBlPRKjNMP0soAIoPOJRwGm3ia05BxAyelTVDWK7gPAQUXxPZNQOeSim6ojwqJV2TgvUnXH9cIt4B7YpkLEcMM1CoEdrgj722oCGgv89ZZBJe4ufA1HV3c7l8uCSqS2oEOE4SyVohNW6MUuvWYNjAFebUjPOXeiZkgfBF8MMO4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