Skip to content

Commit

Permalink
COMP: reformulate a self-assignment to fix -Wself-assign-overloaded w…
Browse files Browse the repository at this point in the history
…arning

The warning was:

Modules/Core/Common/test/itkImageIORegionGTest.cxx:82:8: warning: explicitly assigning value of variable of type 'T' to itself [-Wself-assign-overloaded]
  self = self;
  ~~~~ ^ ~~~~

Thanks to Niels Dekker for the fix.
  • Loading branch information
seanm authored and dzenanz committed Dec 9, 2019
1 parent 1fbe2e5 commit 271e37f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Modules/Core/Common/test/itkImageIORegionGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ void
Expect_CopyAssignableToSelf(const T & value)
{
T self(value);
self = self;

// Slight contortion to avoid self-assignment warning with 'self = self'.
const T& referenceToSelf = self;
self = referenceToSelf;

EXPECT_EQ(self, value);
}

Expand Down

0 comments on commit 271e37f

Please sign in to comment.