Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/static-analyzers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
cmake -S . -B build
-DCMAKE_CXX_STANDARD=23
-DUNITS_ENABLE_ERROR_ON_WARNINGS=ON
-DCMAKE_CXX_FLAGS="-Wstrict-overflow=5 -Werror=strict-overflow"
-DCMAKE_CXX_FLAGS="-Wstrict-overflow=2 -Werror=strict-overflow"

- name: Build
run: cmake --build build --parallel 4
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
gcc9:
containerImage: gcc:9
units.std: 17
units.options: -DCMAKE_CXX_FLAGS="-Wstrict-overflow=5"
units.options: -DCMAKE_CXX_FLAGS="-Wstrict-overflow=2"
gcc11-project_rename:
containerImage: gcc:11
units.std: 17
Expand Down
17 changes: 11 additions & 6 deletions units/units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2998,6 +2998,10 @@ static char getMatchCharacter(char mchar)
// called so coverage isn't expected or required.

// do a segment check in the reverse direction
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-overflow"
#endif
static bool
segmentcheckReverse(const std::string& unit, char closeSegment, int& index)
{
Expand All @@ -3007,12 +3011,10 @@ static bool
// LCOV_EXCL_STOP
}
while (index >= 0) {
const char current = unit[static_cast<size_t>(index)];
// Keep the 0 -> -1 transition explicit to avoid -Wstrict-overflow
// on compilers that rewrite signed decrement-and-compare patterns.
index = (index == 0) ? -1 : index - 1;
if (index >= 0 && unit[static_cast<size_t>(index)] == '\\') {
index = (index == 0) ? -1 : index - 1;
const char current = unit[index];
--index;
if (index >= 0 && unit[index] == '\\') {
--index;
continue;
}
if (current == closeSegment) {
Expand Down Expand Up @@ -3041,6 +3043,9 @@ static bool
return false;
// LCOV_EXCL_STOP
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

// do a segment check in the forward direction
static bool
Expand Down
Loading