Closed as not planned
Description
I ran into an issue with CI patch number differing from our CI patch number of clang-format
. CI and my local clang-format
produced different results. I can reproduce this with the following:
// test_file.cxx
#include <iomanip>
#include <iostream>
int main(int argc, char const *argv[]) {
std::cout
<< std::fixed
<< std::setprecision(1)
<< " - "
<< std::setw(02)
<< 10
<< " | "
<< std::setw(12)
<< "hello"
<< " | "
<< "test: ("
<< std::setw(04)
<< 1
<< ", "
<< std::setw(04)
<< 2
<< ", "
<< std::setw(04)
<< 3
<< ", "
<< std::setw(04)
<< 5
<< ") | "
<< std::endl;
return 0;
}
Running the commands:
$ cat .clang-format
---
BasedOnStyle: Google
ColumnLimit: 120
SpaceBeforeCpp11BracedList: true
Cpp11BracedListStyle: true
AlignAfterOpenBracket: BlockIndent
BinPackArguments: false
BinPackParameters: false
InsertTrailingCommas: Wrapped
BreakConstructorInitializers: BeforeColon
PackConstructorInitializers: CurrentLine
SpacesInParentheses: false
AlignOperands: Align
BreakBeforeBinaryOperators: false
PenaltyIndentedWhitespace: 1
IndentPPDirectives: BeforeHash
$ clang-format-18 --version
Ubuntu clang-format version 18.1.6 (++20240518023229+1118c2e05e67-1~exp1~20240518143321.130)
$ clang-format-18 --style=file test_file.cxx
#include <iomanip>
#include <iostream>
int main(int argc, char const *argv[]) {
std::cout << std::fixed << std::setprecision(1) << " - " << std::setw(02) << 10 << " | " << std::setw(12) << "hello"
<< " | "
<< "test: (" << std::setw(04) << 1 << ", " << std::setw(04) << 2 << ", " << std::setw(04) << 3 << ", "
<< std::setw(04) << 5 << ") | " << std::endl;
return 0;
}
Then with a different version of clang-format
$ clang-format-18 --version
Ubuntu clang-format version 18.1.3 (1)
$ clang-format-18 --style=file test_file.cxx
#include <iomanip>
#include <iostream>
int main(int argc, char const *argv[]) {
std::cout << std::fixed << std::setprecision(1) << " - " << std::setw(02) << 10 << " | " << std::setw(12) << "hello"
<< " | " << "test: (" << std::setw(04) << 1 << ", " << std::setw(04) << 2 << ", " << std::setw(04) << 3
<< ", " << std::setw(04) << 5 << ") | " << std::endl;
return 0;
}
I suspect that a bug was introduced somewhere between 18.1.3
and 18.1.6
, since << " | "
being on it's own line doesn't make sense.