diff --git a/.github/workflows/itk_dict.txt b/.github/workflows/itk_dict.txt index 1ea0fdb6d43..2a15744370e 100644 --- a/.github/workflows/itk_dict.txt +++ b/.github/workflows/itk_dict.txt @@ -226,6 +226,7 @@ Wachowiak Wanlin Wdeprecated Wi +Wmaybe Wtautological Xu Y'CbCr diff --git a/Modules/Core/Common/include/itkRGBAPixel.h b/Modules/Core/Common/include/itkRGBAPixel.h index a5ceeb3bee0..a437cde06b5 100644 --- a/Modules/Core/Common/include/itkRGBAPixel.h +++ b/Modules/Core/Common/include/itkRGBAPixel.h @@ -81,7 +81,13 @@ class ITK_TEMPLATE_EXPORT RGBAPixel : public FixedArray #ifdef ITK_FUTURE_LEGACY_REMOVE RGBAPixel() = default; #else - RGBAPixel() { this->Fill(0); } + constexpr RGBAPixel() + : Superclass(Superclass()) + { + // `: Superclass(Superclass())` is a workaround for an old compiler bug. A simple `: Superclass()` triggered + // warnings from GCC 9.4.0 saying: "warning: '' may be used uninitialized in this function + // [-Wmaybe-uninitialized]". + } #endif /** Pass-through constructor for the Array base class. */ diff --git a/Modules/Core/Common/include/itkRGBPixel.h b/Modules/Core/Common/include/itkRGBPixel.h index f9a879536f9..3d5ff32f369 100644 --- a/Modules/Core/Common/include/itkRGBPixel.h +++ b/Modules/Core/Common/include/itkRGBPixel.h @@ -80,7 +80,13 @@ class ITK_TEMPLATE_EXPORT RGBPixel : public FixedArray #ifdef ITK_FUTURE_LEGACY_REMOVE RGBPixel() = default; #else - RGBPixel() { this->Fill(0); } + constexpr RGBPixel() + : Superclass(Superclass()) + { + // `: Superclass(Superclass())` is a workaround for an old compiler bug. A simple `: Superclass()` triggered + // warnings from GCC 9.4.0 saying: "warning: '' may be used uninitialized in this function + // [-Wmaybe-uninitialized]". + } #endif #if defined(ITK_LEGACY_REMOVE) diff --git a/Modules/Core/Common/test/itkRGBAPixelGTest.cxx b/Modules/Core/Common/test/itkRGBAPixelGTest.cxx index d5760b0ffe9..16b0c285467 100644 --- a/Modules/Core/Common/test/itkRGBAPixelGTest.cxx +++ b/Modules/Core/Common/test/itkRGBAPixelGTest.cxx @@ -22,6 +22,11 @@ #include +static_assert(itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer>() && + itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer>() && + itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer>()); + + // Tests that a RGBAPixel that is "value-initialized" (by empty braces, `{}`) is zero-filled. TEST(RGBAPixel, ValueInitializedIsZeroFilled) { diff --git a/Modules/Core/Common/test/itkRGBPixelGTest.cxx b/Modules/Core/Common/test/itkRGBPixelGTest.cxx index 64a8edb4e0d..4e65888c490 100644 --- a/Modules/Core/Common/test/itkRGBPixelGTest.cxx +++ b/Modules/Core/Common/test/itkRGBPixelGTest.cxx @@ -22,6 +22,11 @@ #include +static_assert(itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer>() && + itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer>() && + itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer>()); + + // Tests that a RGBPixel that is "value-initialized" (by empty braces, `{}`) is zero-filled. TEST(RGBPixel, ValueInitializedIsZeroFilled) {