Skip to content

Commit b5b105d

Browse files
authored
Merge pull request #4608 from hjmjohnson/ubuntu2404-fixes-issue-4607
COMP: Ubuntu2404 fixes issue 4607
2 parents f408b77 + 462a874 commit b5b105d

File tree

10 files changed

+45
-36
lines changed

10 files changed

+45
-36
lines changed

.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ StatementMacros:
152152
- ITK_GCC_SUPPRESS_Wformat_nonliteral
153153
- CLANG_PRAGMA_PUSH
154154
- CLANG_PRAGMA_POP
155-
- CLANG_SUPPRESS_Wcpp14_extensions
156155
- INTEL_PRAGMA_WARN_PUSH
157156
- INTEL_PRAGMA_WARN_POP
158157
- INTEL_SUPPRESS_warning_1292

Modules/Core/Common/include/itkExtractImageFilter.hxx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ ExtractImageFilter<TInputImage, TOutputImage>::SetExtractionRegion(InputImageReg
6262
"InputImageDimension must be greater than OutputImageDimension");
6363
m_ExtractionRegion = extractRegion;
6464

65-
unsigned int nonzeroSizeCount = 0;
6665
InputImageSizeType inputSize = extractRegion.GetSize();
6766
OutputImageSizeType outputSize;
6867
outputSize.Fill(0);
@@ -73,12 +72,16 @@ ExtractImageFilter<TInputImage, TOutputImage>::SetExtractionRegion(InputImageReg
7372
* check to see if the number of non-zero entries in the extraction region
7473
* matches the number of dimensions in the output image.
7574
*/
75+
unsigned int nonzeroSizeCount = 0;
7676
for (unsigned int i = 0; i < InputImageDimension; ++i)
7777
{
7878
if (inputSize[i])
7979
{
80-
outputSize[nonzeroSizeCount] = inputSize[i];
81-
outputIndex[nonzeroSizeCount] = extractRegion.GetIndex()[i];
80+
if (nonzeroSizeCount < OutputImageDimension)
81+
{
82+
outputSize[nonzeroSizeCount] = inputSize[i];
83+
outputIndex[nonzeroSizeCount] = extractRegion.GetIndex()[i];
84+
}
8285
++nonzeroSizeCount;
8386
}
8487
}
@@ -116,11 +119,7 @@ ExtractImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()
116119
outputPtr->SetLargestPossibleRegion(m_OutputImageRegion);
117120

118121
// Set the output spacing and origin
119-
const ImageBase<InputImageDimension> * phyData;
120-
121-
phyData = dynamic_cast<const ImageBase<InputImageDimension> *>(this->GetInput());
122-
123-
if (phyData)
122+
if (this->GetInput())
124123
{
125124
// Copy what we can from the image from spacing and origin of the input
126125
// This logic needs to be augmented with logic that select which

Modules/Core/Common/include/itkMacro.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,16 @@ namespace itk
120120
#if defined(__clang__) && defined(__has_warning)
121121
# define CLANG_PRAGMA_PUSH ITK_PRAGMA(clang diagnostic push)
122122
# define CLANG_PRAGMA_POP ITK_PRAGMA(clang diagnostic pop)
123-
# if __has_warning("-Wc++14-extensions")
124-
# define CLANG_SUPPRESS_Wcpp14_extensions ITK_PRAGMA(clang diagnostic ignored "-Wc++14-extensions")
125-
# else
126-
# define CLANG_SUPPRESS_Wcpp14_extensions
127-
# endif
128123
#else
129124
# define CLANG_PRAGMA_PUSH
130125
# define CLANG_PRAGMA_POP
131-
# define CLANG_SUPPRESS_Wcpp14_extensions
126+
#endif
127+
128+
#if !defined(ITK_LEGACY_REMOVE)
129+
// Issue warning if deprecated preprocessor flag is used.
130+
# define CLANG_SUPPRESS_Wcpp14_extensions \
131+
[[deprecated("Remove deprecated CLANG_SUPPRESS_Wcpp14_extensions c++14 warning suppression")]] void * \
132+
CLANG_SUPPRESS_Wcpp14_extensions = nullptr;
132133
#endif
133134

134135
// Intel compiler convenience macros

Modules/Core/Common/include/itkMultiThreaderBase.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,13 @@ ITK_GCC_PRAGMA_DIAG_PUSH()
238238
ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")
239239
INTEL_PRAGMA_WARN_PUSH
240240
INTEL_SUPPRESS_warning_1292
241-
CLANG_PRAGMA_PUSH
242-
CLANG_SUPPRESS_Wcpp14_extensions
243241
// clang-format on
244242
# ifdef ITK_LEGACY_SILENT
245243
struct ThreadInfoStruct
246244
# else
247245
struct [[deprecated("Use WorkUnitInfo, ThreadInfoStruct is deprecated since ITK 5.0")]] ThreadInfoStruct
248246
# endif
249247
// clang-format off
250-
CLANG_PRAGMA_POP
251248
INTEL_PRAGMA_WARN_POP
252249
// clang-format on
253250
{

Modules/Core/Common/include/itkNeighborhood.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ class ITK_TEMPLATE_EXPORT Neighborhood
136136
SizeValueType
137137
GetRadius(DimensionValueType n) const
138138
{
139-
return m_Radius[n];
139+
return m_Radius.at(n);
140140
}
141141

142142
/** Returns the size (total length) of the neighborhood along
143143
* a specified dimension. */
144144
SizeValueType
145145
GetSize(DimensionValueType n) const
146146
{
147-
return m_Size[n];
147+
return m_Size.at(n);
148148
}
149149

150150
/** Returns the size (total length of sides) of the neighborhood. */

Modules/Core/Common/include/itkNeighborhoodOperator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ class ITK_TEMPLATE_EXPORT NeighborhoodOperator : public Neighborhood<TPixel, VDi
9393
void
9494
SetDirection(const unsigned long direction)
9595
{
96+
if (direction >= VDimension)
97+
{
98+
itkExceptionMacro(<< " Can not set direction " << direction << " greater than dimensionality of neighborhood "
99+
<< VDimension);
100+
}
96101
m_Direction = direction;
97102
}
98103

Modules/Core/Common/test/itkShapedImageNeighborhoodRangeGTest.cxx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdVectorConstructor)
350350
// second argument of std::reverse (which requires bidirectional iterators).
351351
TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdReverseCopy)
352352
{
353-
using PixelType = unsigned char;
353+
using PixelType = unsigned short;
354354
using ImageType = itk::Image<PixelType>;
355355
enum
356356
{
@@ -366,11 +366,14 @@ TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdReverseCopy)
366366
itk::ShapedImageNeighborhoodRange<ImageType> range{ *image, location, offsets };
367367

368368
const unsigned int numberOfNeighborhoodPixels = 3;
369+
ASSERT_EQ(numberOfNeighborhoodPixels, range.size());
369370

370371
const std::vector<PixelType> stdVector(range.begin(), range.end());
371-
std::vector<PixelType> reversedStdVector1(numberOfNeighborhoodPixels);
372-
std::vector<PixelType> reversedStdVector2(numberOfNeighborhoodPixels);
373-
std::vector<PixelType> reversedStdVector3(numberOfNeighborhoodPixels);
372+
ASSERT_EQ(stdVector.size(), numberOfNeighborhoodPixels);
373+
374+
std::vector<PixelType> reversedStdVector1(numberOfNeighborhoodPixels);
375+
std::vector<PixelType> reversedStdVector2(numberOfNeighborhoodPixels);
376+
std::vector<PixelType> reversedStdVector3(numberOfNeighborhoodPixels);
374377

375378
// Checks bidirectionality of the ShapedImageNeighborhoodRange iterators!
376379
std::reverse_copy(stdVector.cbegin(), stdVector.cend(), reversedStdVector1.begin());
@@ -455,11 +458,13 @@ TEST(ShapedImageNeighborhoodRange, CanBeUsedAsExpressionOfRangeBasedForLoop)
455458
const itk::Size<ImageType::ImageDimension> radius = { { 0, 1 } };
456459
const std::vector<itk::Offset<ImageType::ImageDimension>> offsets =
457460
itk::GenerateRectangularImageNeighborhoodOffsets(radius);
458-
RangeType range{ *image, location, offsets };
461+
RangeType range{ *image, location, offsets };
462+
constexpr PixelType reference_value = 42;
459463

460464
for (const PixelType pixel : range)
461465
{
462-
EXPECT_NE(pixel, 42);
466+
// Initially not set to reference value
467+
EXPECT_NE(pixel, reference_value);
463468
}
464469

465470
// Note: instead of 'iterator::reference', you may also type 'auto&&', but
@@ -471,12 +476,12 @@ TEST(ShapedImageNeighborhoodRange, CanBeUsedAsExpressionOfRangeBasedForLoop)
471476
// https://bugs.llvm.org/show_bug.cgi?id=37392
472477
for (RangeType::iterator::reference pixel : range)
473478
{
474-
pixel = 42;
479+
pixel = reference_value;
475480
}
476481

477482
for (const PixelType pixel : range)
478483
{
479-
EXPECT_EQ(pixel, 42);
484+
EXPECT_EQ(pixel, reference_value);
480485
}
481486
}
482487

@@ -895,7 +900,7 @@ TEST(ShapedImageNeighborhoodRange, SupportsSubscript)
895900

896901
TEST(ShapedImageNeighborhoodRange, ProvidesReverseIterators)
897902
{
898-
using PixelType = unsigned char;
903+
using PixelType = unsigned short;
899904
using ImageType = itk::Image<PixelType>;
900905
using RangeType = itk::ShapedImageNeighborhoodRange<ImageType>;
901906
enum
@@ -911,12 +916,15 @@ TEST(ShapedImageNeighborhoodRange, ProvidesReverseIterators)
911916
itk::GenerateRectangularImageNeighborhoodOffsets(radius);
912917
RangeType range{ *image, location, offsets };
913918

914-
const unsigned int numberOfNeighborhoodPixels = 3;
919+
constexpr unsigned int numberOfNeighborhoodPixels = 3;
920+
ASSERT_EQ(numberOfNeighborhoodPixels, range.size());
915921

916922
const std::vector<PixelType> stdVector(range.begin(), range.end());
917-
std::vector<PixelType> reversedStdVector1(numberOfNeighborhoodPixels);
918-
std::vector<PixelType> reversedStdVector2(numberOfNeighborhoodPixels);
919-
std::vector<PixelType> reversedStdVector3(numberOfNeighborhoodPixels);
923+
ASSERT_EQ(stdVector.size(), numberOfNeighborhoodPixels);
924+
925+
std::vector<PixelType> reversedStdVector1(numberOfNeighborhoodPixels);
926+
std::vector<PixelType> reversedStdVector2(numberOfNeighborhoodPixels);
927+
std::vector<PixelType> reversedStdVector3(numberOfNeighborhoodPixels);
920928

921929
std::reverse_copy(stdVector.cbegin(), stdVector.cend(), reversedStdVector1.begin());
922930

Modules/Core/QuadEdgeMesh/test/itkQuadEdgeMeshEulerOperatorSplitEdgeTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ itkQuadEdgeMeshEulerOperatorSplitEdgeTest(int, char *[])
4242
auto splitEdge = SplitEdge::New();
4343
std::cout << " "
4444
<< "Test No Mesh Input";
45-
if (splitEdge->Evaluate((QEType *)1))
45+
if (splitEdge->Evaluate((QEType *)0))
4646
{
4747
std::cout << "FAILED." << std::endl;
4848
return EXIT_FAILURE;

Modules/Filtering/ImageFusion/include/itkLabelMapContourOverlayImageFilter.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ LabelMapContourOverlayImageFilter<TLabelMap, TFeatureImage, TOutputImage>::Befor
157157
srad.Fill(typename RadiusType::SizeValueType{});
158158
for (unsigned int i = 0, j = 0; i < ImageDimension; ++i)
159159
{
160-
if (j != static_cast<unsigned int>(m_SliceDimension))
160+
if (j != static_cast<unsigned int>(m_SliceDimension) && (j < (ImageDimension - 1)))
161161
{
162162
srad[j] = m_ContourThickness[i];
163163
++j;

Modules/Filtering/ImageIntensity/include/itkSymmetricEigenAnalysisImageFilter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class SymmetricEigenAnalysisFunction
5656
inline TOutput
5757
operator()(const TInput & x) const
5858
{
59-
TOutput eigenValues;
59+
TOutput eigenValues{};
6060

6161
m_Calculator.ComputeEigenValues(x, eigenValues);
6262
return eigenValues;

0 commit comments

Comments
 (0)