<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89696>89696</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] Failure when formatting a nested structure containing a lint-suppression comment
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mitchgrout
</td>
</tr>
</table>
<pre>
**Version**: 17.0.2
**Platform**: Windows 10 (mingw64), x86_64
**.clang-format**:
```yml
---
BasedOnStyle: LLVM
Language: Cpp
Standard: c++17
ColumnLimit: 120
AlignArrayOfStructures: Left
```
**main.c**:
```c
object_t obj =
{
.outer =
{
.w = 0,
.x = 1, //lint some comment here
.y = 2,
.z = 3
}
};
```
Running the command `clang-format -style=file main.c` triggers a failure with the following stack dump:
```
Stack dump:
0. Program arguments: "C:\\Program Files\\LLVM\\bin\\clang-format.exe" -style=file main.c
Exception Code: 0xC0000005
#0 0x00007ff744ab591b C:\Program Files\LLVM\bin\clang-format.exe 0xe591b C:\Program Files\LLVM\bin\clang-format.exe 0xe5373
#1 0x00007ff744ab591b C:\Program Files\LLVM\bin\clang-format.exe 0xe3c20 C:\Program Files\LLVM\bin\clang-format.exe 0xe0d26
#2 0x00007ff744ab591b C:\Program Files\LLVM\bin\clang-format.exe 0x5bd3d C:\Program Files\LLVM\bin\clang-format.exe 0xc54d1
#3 0x00007ff744ab591b C:\Program Files\LLVM\bin\clang-format.exe 0x6eed7 C:\Program Files\LLVM\bin\clang-format.exe 0x51462
#4 0x00007ff744ab591b C:\Program Files\LLVM\bin\clang-format.exe 0x53e89 C:\Program Files\LLVM\bin\clang-format.exe 0x572d
#5 0x00007ff744ab591b C:\Program Files\LLVM\bin\clang-format.exe 0x39b6 C:\Program Files\LLVM\bin\clang-format.exe 0x1b0d40
#6 0x00007ff744ab591b (C:\Program Files\LLVM\bin\clang-format.exe+0xe591b)
#7 0x00007ff744ab5373 (C:\Program Files\LLVM\bin\clang-format.exe+0xe5373)
0x00007FF744AB591B, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0xE591B byte(s)
0x00007FF744AB5373, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0xE5373 byte(s)
0x00007FF744AB3C20, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0xE3C20 byte(s)
0x00007FF744AB0D26, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0xE0D26 byte(s)
0x00007FF744A2BD3D, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0x5BD3D byte(s)
0x00007FF744A954D1, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0xC54D1 byte(s)
0x00007FF744A3EED7, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0x6EED7 byte(s)
0x00007FF744A21462, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0x51462 byte(s)
0x00007FF744A23E89, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0x53E89 byte(s)
0x00007FF7449D572D, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0x572D byte(s)
0x00007FF7449D39B6, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0x39B6 byte(s)
0x00007FF744B80D40, C:\Program Files\LLVM\bin\clang-format.exe(0x00007FF7449D0000) + 0x1B0D40 byte(s)
0x00007FFC55B27344, C:\Windows\System32\KERNEL32.DLL(0x00007FFC55B10000) + 0x17344 byte(s), BaseThreadInitThunk() + 0x14 byte(s)
0x00007FFC55E026B1, C:\Windows\SYSTEM32\ntdll.dll(0x00007FFC55DB0000) + 0x526B1 byte(s), RtlUserThreadStart() + 0x21 byte(s)
```
This is a stripped-down example from a larger code-base. `object_t` represents a union, with `.outer` being one of the possible variants. Some extra notes:
- If a trailing comma is attached to `.z`, no failure occurs, but `.y` will be de-dented heavily
- If `.w` is removed, no error occurs
- If a space between `//` and `lint` is added, no error occurs
- If the comment is removed, no error occurs
- If the `.outer` declaration is removed, no error occurs
- If `AlignArrayOfStructures` is removed, no error occurs
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0WN1u2zwSfRr6hrBAUX_WhS8iyQY-bLotmmwXe1VQ4lhmS5EGScV2n35ByYl_kMZFGhtFI5Mz55wZjmQcMWtFqwDmKClQUk1Y79bazDvhmnVrdO8mteb7OaJ3iN59A2OFVuMXFN3hMAtIQBGpELkbV79I5lbadMeY_wrF9dbikGBEZ51Q7TaNEc0RLfFuln5P49P8oJFMtVMPwdwLyCFi_D8l4799J8eV6XQ6XhTMAv-sHtxegqe-v__2ady5Z6rtWTusnn_KzWYMeXBMcWa4D2kQLRAtwmzcKrXsO3UvOuEuAEJKxpA7KVp1Zwzbf149ONM3rjdgBxGwchfKz8oZauyYUEHzdr3N-F3XP6Bx3x3W9Q-MouoQlRXjBcaB7h2Y4xbGJ5sYB1u_hQmi5cniblgM_aEgukR0KYVy2OoOcKO7DpTDazBwkrEfMug5zK9hMToSv8irUFS80YavvVJCtditR0KmOPY1n0wDntrxYKuVkIAPLUsJdka0LRiLGV4xIXsDeCvcesBaaSn11iNbx5qfmPfd5ncNfpmDyzgSjKf9xejWsA4z0_a-JcP5IkpLH5mUKCmfI5ZCgh2XhiEcrmqhxovTqgLYAaL09eIG9sWugY0TWuFS82GCya4kwyc5NBrRiGCy80vZapXFMauTPKzxQdilqoOkUc-lGEx28HfJURYddYUfqStqKHl3MuE0PeqiH6grqXnE35vcJDEPj7qiD9SVAvDs3UWFcUqPuuKP7FcEs_zdyRnlR1nJB8qK8jp9b25YEx6To670NV2Izt4Dj2hxuCf9z-YLRXZJEWXRX1L4O_eZ4gC-XGZxfFckeVj4H4f3gc9OwfLKXyOaY0QLTHYLj43rvfOB9nf8g7Qb8fvGXeGPSkpuxe-xr_GTiqa34vfYV_hp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