Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMP: Ubuntu2404 fixes issue 4607 #4608

1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ StatementMacros:
- ITK_GCC_SUPPRESS_Wformat_nonliteral
- CLANG_PRAGMA_PUSH
- CLANG_PRAGMA_POP
- CLANG_SUPPRESS_Wcpp14_extensions
- INTEL_PRAGMA_WARN_PUSH
- INTEL_PRAGMA_WARN_POP
- INTEL_SUPPRESS_warning_1292
Expand Down
15 changes: 7 additions & 8 deletions Modules/Core/Common/include/itkExtractImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ ExtractImageFilter<TInputImage, TOutputImage>::SetExtractionRegion(InputImageReg
"InputImageDimension must be greater than OutputImageDimension");
m_ExtractionRegion = extractRegion;

unsigned int nonzeroSizeCount = 0;
InputImageSizeType inputSize = extractRegion.GetSize();
OutputImageSizeType outputSize;
outputSize.Fill(0);
Expand All @@ -73,12 +72,16 @@ ExtractImageFilter<TInputImage, TOutputImage>::SetExtractionRegion(InputImageReg
* check to see if the number of non-zero entries in the extraction region
* matches the number of dimensions in the output image.
*/
unsigned int nonzeroSizeCount = 0;
for (unsigned int i = 0; i < InputImageDimension; ++i)
{
if (inputSize[i])
{
outputSize[nonzeroSizeCount] = inputSize[i];
outputIndex[nonzeroSizeCount] = extractRegion.GetIndex()[i];
if (nonzeroSizeCount < OutputImageDimension)
{
outputSize[nonzeroSizeCount] = inputSize[i];
outputIndex[nonzeroSizeCount] = extractRegion.GetIndex()[i];
}
++nonzeroSizeCount;
}
}
Expand Down Expand Up @@ -116,11 +119,7 @@ ExtractImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()
outputPtr->SetLargestPossibleRegion(m_OutputImageRegion);

// Set the output spacing and origin
const ImageBase<InputImageDimension> * phyData;

phyData = dynamic_cast<const ImageBase<InputImageDimension> *>(this->GetInput());

if (phyData)
if (this->GetInput())
{
// Copy what we can from the image from spacing and origin of the input
// This logic needs to be augmented with logic that select which
Expand Down
13 changes: 7 additions & 6 deletions Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ namespace itk
#if defined(__clang__) && defined(__has_warning)
# define CLANG_PRAGMA_PUSH ITK_PRAGMA(clang diagnostic push)
# define CLANG_PRAGMA_POP ITK_PRAGMA(clang diagnostic pop)
# if __has_warning("-Wc++14-extensions")
# define CLANG_SUPPRESS_Wcpp14_extensions ITK_PRAGMA(clang diagnostic ignored "-Wc++14-extensions")
# else
# define CLANG_SUPPRESS_Wcpp14_extensions
# endif
#else
# define CLANG_PRAGMA_PUSH
# define CLANG_PRAGMA_POP
# define CLANG_SUPPRESS_Wcpp14_extensions
#endif

#if !defined(ITK_LEGACY_REMOVE)
// Issue warning if deprecated preprocessor flag is used.
# define CLANG_SUPPRESS_Wcpp14_extensions \
[[deprecated("Remove deprecated CLANG_SUPPRESS_Wcpp14_extensions c++14 warning suppression")]] void * \
CLANG_SUPPRESS_Wcpp14_extensions = nullptr;
#endif

// Intel compiler convenience macros
Expand Down
3 changes: 0 additions & 3 deletions Modules/Core/Common/include/itkMultiThreaderBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,13 @@ ITK_GCC_PRAGMA_DIAG_PUSH()
ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")
INTEL_PRAGMA_WARN_PUSH
INTEL_SUPPRESS_warning_1292
CLANG_PRAGMA_PUSH
CLANG_SUPPRESS_Wcpp14_extensions
// clang-format on
# ifdef ITK_LEGACY_SILENT
struct ThreadInfoStruct
# else
struct [[deprecated("Use WorkUnitInfo, ThreadInfoStruct is deprecated since ITK 5.0")]] ThreadInfoStruct
# endif
// clang-format off
CLANG_PRAGMA_POP
INTEL_PRAGMA_WARN_POP
// clang-format on
{
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkNeighborhood.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ class ITK_TEMPLATE_EXPORT Neighborhood
SizeValueType
GetRadius(DimensionValueType n) const
{
return m_Radius[n];
return m_Radius.at(n);
}
hjmjohnson marked this conversation as resolved.
Show resolved Hide resolved

/** Returns the size (total length) of the neighborhood along
* a specified dimension. */
SizeValueType
GetSize(DimensionValueType n) const
{
return m_Size[n];
return m_Size.at(n);
}

/** Returns the size (total length of sides) of the neighborhood. */
Expand Down
5 changes: 5 additions & 0 deletions Modules/Core/Common/include/itkNeighborhoodOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ class ITK_TEMPLATE_EXPORT NeighborhoodOperator : public Neighborhood<TPixel, VDi
void
SetDirection(const unsigned long direction)
{
if (direction >= VDimension)
{
itkExceptionMacro(<< " Can not set direction " << direction << " greater than dimensionality of neighborhood "
<< VDimension);
}
m_Direction = direction;
}

Expand Down
34 changes: 21 additions & 13 deletions Modules/Core/Common/test/itkShapedImageNeighborhoodRangeGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdVectorConstructor)
// second argument of std::reverse (which requires bidirectional iterators).
TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdReverseCopy)
{
using PixelType = unsigned char;
using PixelType = unsigned short;
hjmjohnson marked this conversation as resolved.
Show resolved Hide resolved
using ImageType = itk::Image<PixelType>;
enum
{
Expand All @@ -366,11 +366,14 @@ TEST(ShapedImageNeighborhoodRange, IteratorsCanBePassedToStdReverseCopy)
itk::ShapedImageNeighborhoodRange<ImageType> range{ *image, location, offsets };

const unsigned int numberOfNeighborhoodPixels = 3;
ASSERT_EQ(numberOfNeighborhoodPixels, range.size());

const std::vector<PixelType> stdVector(range.begin(), range.end());
std::vector<PixelType> reversedStdVector1(numberOfNeighborhoodPixels);
std::vector<PixelType> reversedStdVector2(numberOfNeighborhoodPixels);
std::vector<PixelType> reversedStdVector3(numberOfNeighborhoodPixels);
ASSERT_EQ(stdVector.size(), numberOfNeighborhoodPixels);

std::vector<PixelType> reversedStdVector1(numberOfNeighborhoodPixels);
std::vector<PixelType> reversedStdVector2(numberOfNeighborhoodPixels);
std::vector<PixelType> reversedStdVector3(numberOfNeighborhoodPixels);

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

for (const PixelType pixel : range)
{
EXPECT_NE(pixel, 42);
// Initially not set to reference value
EXPECT_NE(pixel, reference_value);
}

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

for (const PixelType pixel : range)
{
EXPECT_EQ(pixel, 42);
EXPECT_EQ(pixel, reference_value);
}
}

Expand Down Expand Up @@ -895,7 +900,7 @@ TEST(ShapedImageNeighborhoodRange, SupportsSubscript)

TEST(ShapedImageNeighborhoodRange, ProvidesReverseIterators)
{
using PixelType = unsigned char;
using PixelType = unsigned short;
using ImageType = itk::Image<PixelType>;
using RangeType = itk::ShapedImageNeighborhoodRange<ImageType>;
enum
Expand All @@ -911,12 +916,15 @@ TEST(ShapedImageNeighborhoodRange, ProvidesReverseIterators)
itk::GenerateRectangularImageNeighborhoodOffsets(radius);
RangeType range{ *image, location, offsets };

const unsigned int numberOfNeighborhoodPixels = 3;
constexpr unsigned int numberOfNeighborhoodPixels = 3;
ASSERT_EQ(numberOfNeighborhoodPixels, range.size());

const std::vector<PixelType> stdVector(range.begin(), range.end());
std::vector<PixelType> reversedStdVector1(numberOfNeighborhoodPixels);
std::vector<PixelType> reversedStdVector2(numberOfNeighborhoodPixels);
std::vector<PixelType> reversedStdVector3(numberOfNeighborhoodPixels);
ASSERT_EQ(stdVector.size(), numberOfNeighborhoodPixels);

std::vector<PixelType> reversedStdVector1(numberOfNeighborhoodPixels);
std::vector<PixelType> reversedStdVector2(numberOfNeighborhoodPixels);
std::vector<PixelType> reversedStdVector3(numberOfNeighborhoodPixels);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ itkQuadEdgeMeshEulerOperatorSplitEdgeTest(int, char *[])
auto splitEdge = SplitEdge::New();
std::cout << " "
<< "Test No Mesh Input";
if (splitEdge->Evaluate((QEType *)1))
if (splitEdge->Evaluate((QEType *)0))
{
std::cout << "FAILED." << std::endl;
return EXIT_FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ LabelMapContourOverlayImageFilter<TLabelMap, TFeatureImage, TOutputImage>::Befor
srad.Fill(typename RadiusType::SizeValueType{});
for (unsigned int i = 0, j = 0; i < ImageDimension; ++i)
{
if (j != static_cast<unsigned int>(m_SliceDimension))
if (j != static_cast<unsigned int>(m_SliceDimension) && (j < (ImageDimension - 1)))
{
srad[j] = m_ContourThickness[i];
++j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SymmetricEigenAnalysisFunction
inline TOutput
operator()(const TInput & x) const
{
TOutput eigenValues;
TOutput eigenValues{};

m_Calculator.ComputeEigenValues(x, eigenValues);
return eigenValues;
Expand Down