<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68404>68404</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format-18 `ColumnLimit: 0` breaks formatting when encountering empty `#if 0 ... #endif` section
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MartinsSmirnovs
</td>
</tr>
</table>
<pre>
Given following `.clang-format` file:
```
ColumnLimit: 0
```
And following `foo.cpp` source file:
```
struct Foo {
Foo() : a(2) {
#if 0
// comment
#endif
}
Foo &operator+=(const Foo &) {
return *this;
}
int a = 0;
};
```
I expect that ```clang-format-18 foo.cpp``` will not perform formatting, however, it does:
```
$ clang-format-18 foo.cpp
struct Foo {
Foo() : a(2){
#if 0
// comment
#endif
}
Foo
& operator+=(const Foo &) {
return *this;
}
int a = 0;
};
```
After changing the value of `ColumnLimit: 0` to something like 80, the issue is no more. We can also add some code into the `#if 0` part, and `clang-format` will not perform formatting in broken way anymore with `ColumnLimit: 0`.
`clang-format-18` version:
```
$ clang-format-18 --version
Ubuntu clang-format version 18.0.0 (++20230929042255+ab472cd4ea12-1~exp1~20230929042400.1214)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVM2O4zYTfBrq0rBAUT-WDjrYa_jDBySnIMiZoloWMxQpkC1757LPHlAz9oyd9QbBxhAskazuanYVKUPQJ4vYsnLPykMiFxqdb3-VnrQNv03aW3cOSef61_Z_-owWBmeMu2h7AlbxVBlpT5vB-UkSqzgM2iDLd4wfGN-xir8_6_CLM8tkf9GTJpbvgH8XtLP9PcXgXKrmOSYPbvEKf8gRyC-K4OgcsO3-bQ7ikImaiQYisWSiFuvgimAi18O1IAAAJo5MHEG5aUJLNxDaXg9XFNse3hc-WICJys3oJTnPxJ7lByZq5Wyg6-odb6TySIu3wMSORh1Yvn-aX1sCCSw_AL_BIuj2fd-K_wN-nVER0CgJboufFdtkNXz09-2BizYGrCOY0UcYvGFJ2xMTX2B0Fzyjj5-aoHcYnmnBRAFP2OAHan1frJ_T6vp77GnkeoSICv4jCX9Wwd1A6EGN0p7iYaAR4SzNguCGqOffzlPFgRwENyGNMcDoF4SaR6lirA5hif9gHUzOYwp_IChpQZrgQPb9GgrK9RgrdWtQLOa94xWHWXqK6aTt4cFL_2Ad0BY6717QwkW-grSvsQS4aBqf7CWFW1MeXBSpzuiDdvbfeG-zuQatkN-7xdJyh7pmhaxOecph9eGeib3gIueNaHghRFkysZddsRWqL1BmYpN9w69z9u0TqOA8zURWROPel5f0bd43eSMTbLOqqcq6rqoyGds8y5phyEWNTS2bRpVlIbqqKyuRyWro-kS3kSDjvMp4vi3KdCux6bKsyLK65rmqWMFxktqkxpyn1PlTsireVnXBi8TIDk1Y73kh7oQTIt78vo1hm245BVZwowOFj0SkyWD72NAnHuw8ypfwWfvLiBbQKrdYQh9ncJrp9ZO5IE1TuJ3aeNejIu1ssnjTjkTzesusJ_2kaVy6VLmJiWOs8P21mb37ExUxcVz3HZg4rlv_KwAA___mhPYh">