COMP: Suppress GCC -Waggressive-loop-optimizations false positive#5966
Conversation
GCC 11.4 emits "iteration 2 invokes undefined behavior" warnings for template-parameterized loops over FixedArray-based types in itkWarpImageFilter.hxx and itkESMDemonsRegistrationFunction.hxx. These are false positives: the loop bound (ImageDimension) matches the array size, but GCC's optimizer cannot prove this across complex template instantiations. Suppress via CTEST_CUSTOM_WARNING_EXCEPTION since ITK does not use #pragma GCC diagnostic anywhere in the codebase. CDash builds: 11129866 (Ubuntu-22.04-gcc11.4-Rel-Python) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@blowekamp This was identified by running the updated version of the skill |
|
This looks reasonable. However unfortunately we tried a similar approach with the Eigen warnings and it did not work. In the following PR I updated to a simplified regex by removing the specific warning segment of the express, not ideal but it did suppress it. https://github.com/InsightSoftwareConsortium/ITK/pull/5949/changes Unfortunately there is some mystery to what will work. I don't see any harm in this change, as long as we are keeping the expressions organized. |
|
Interesting! Do you possibly have a link to the specific CDash page? |
|
Thanks @blowekamp So somewhere here: Saying: I guess iteration 2 is when I noticed that the warning even appears when no warnings are enabled at all! At https://gcc.godbolt.org/z/esePs6ePE int GetLargeInteger()
{
int result{1};
for (int i = 0; i < 4; ++i)
result += i*1000000000;
return result;
}On GCC 15.2, having |
Summary
-Waggressive-loop-optimizationswarnings in CDash nightly buildsitkWarpImageFilter.hxxanditkESMDemonsRegistrationFunction.hxxwhere template-parameterized loops overFixedArray-based types trigger "iteration 2 invokes undefined behavior"CTEST_CUSTOM_WARNING_EXCEPTIONinCTestCustom.cmake.inCDash Reference
Build 11129866 (Ubuntu-22.04-gcc11.4-Rel-Python, corista.kitware)
Test plan
🤖 Generated with Claude Code