You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
clang-format crashes with an error segmentation fault. As I found out, this is due to the overflow of the Level value for the comment line. Overflow occurs in line 393 of the file clang/lib/Format/UnwrappedLineFormatter.cpp:
...
if (!(*CompactedLine)->InPPDirective)
(*CompactedLine)->Level -= OutdentBy;
...
OutdentBy turns out to be greater than the value (*CompactedLine)->Level, which causes an overflow.
I see the following way to solve the problem:
...
if (!(*CompactedLine)->InPPDirective)
(*CompactedLine)->Level -= std:min(OutdentBy, (*CompactedLine)->Level);
...
The text was updated successfully, but these errors were encountered:
Fixing the clang-format crash with the segmentation fault error when
formatting code with nested namespaces.
Fixesllvm#64701.
Differential Revision: https://reviews.llvm.org/D158363
When formatting this part of the code:
with the following style settings:
clang-format crashes with an error segmentation fault. As I found out, this is due to the overflow of the Level value for the comment line. Overflow occurs in line 393 of the file clang/lib/Format/UnwrappedLineFormatter.cpp:
OutdentBy turns out to be greater than the value (*CompactedLine)->Level, which causes an overflow.
I see the following way to solve the problem:
The text was updated successfully, but these errors were encountered: