Skip to content

COMP: Fix GCC warnings in ITK proxTV build - #1

Draft
hjmjohnson wants to merge 3 commits into
InsightSoftwareConsortium:for/itk-proxtv-3.3.0-69062fe5from
hjmjohnson:warnings-cleanup-gcc
Draft

COMP: Fix GCC warnings in ITK proxTV build#1
hjmjohnson wants to merge 3 commits into
InsightSoftwareConsortium:for/itk-proxtv-3.3.0-69062fe5from
hjmjohnson:warnings-cleanup-gcc

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Clears all GCC warnings emitted when ITK builds proxTV (OpenMP intentionally not linked). Targets the for/itk-proxtv-3.3.0-69062fe5 integration branch that ITK consumes. All changes are behavior-preserving for valid inputs; the TotalVariation/ProxTV image-filter tests pass.

Warnings fixed
Category Count Fix
-Wunknown-pragmas 36 Guard OpenMP directives behind #ifdef _OPENMP and MSVC #pragma warning behind #ifdef _MSC_VER, so builds without OpenMP no longer warn
-Wsign-compare 12 size_t loop counters against size_t bounds in the 2D Douglas–Rachford column/row passes (TV2Dopt, TV2DWopt); cast the segment/interior bounds in the taut-string solver (TVL1opt_tautstring)
-Wmisleading-indentation 3 Split the NORM macro's trailing statement onto its own continuation line (TVL2opt)
-Wstringop-overflow= / -Walloc-size-larger-than= 4 Validate n >= 2 (more_TV2, morePG_TV2) and npen >= 1 (PD_TV, PDR_TV) at entry, so the dependent memcpy/calloc sizes can no longer be a signed-to-size_t huge value
Notes
  • The #ifdef _OPENMP guards keep the OpenMP directives active in OpenMP-enabled builds and inert (no -Wunknown-pragmas) when OpenMP is not linked, which is ITK's configuration.
  • The input-validation guards are the only functional change: for n < 2 / npen < 1 the solver now sets info[INFO_RC] = RC_ERROR and returns instead of computing an underflowed size. Valid problems (n >= 2, npen >= 1) are unaffected.

Wrap the OpenMP work-sharing directives in #ifdef _OPENMP and the MSVC
#pragma warning suppressions in #ifdef _MSC_VER so GCC/Clang builds without
OpenMP no longer emit -Wunknown-pragmas.
Use size_t loop counters against size_t bounds in the 2D Douglas-Rachford
column/row passes, cast the segment/interior bounds in the taut-string
solver, and split the NORM macro's trailing statement onto its own line.
Reject n < 2 in more_TV2/morePG_TV2 and npen < 1 in PD_TV/PDR_TV before the
dependent memcpy/calloc sizes are computed, so the signed-to-size_t size
arguments can no longer be a huge value (-Wstringop-overflow, -Walloc-size-larger-than).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant