Skip to content

Commit 1582014

Browse files
committed
COMP: Fix set but not used warnings
1 parent 00e2fad commit 1582014

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Core/Common/ReturnObjectFromFunction/Code.cxx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,28 @@ main()
5757
std::cout << smartPointer->GetLargestPossibleRegion() << std::endl;
5858
}
5959

60+
// Common failure modes
6061
{
61-
ImageType * pointer = ReturnPointer();
6262
// This crashes the program because the smart pointer created in the function goes out of scope and gets deleted
6363
// because it is returned as a normal pointer.
64+
65+
// ImageType * pointer = ReturnPointer();
6466
// std::cout << pointer->GetLargestPossibleRegion() << std::endl;
65-
pointer = nullptr; // Here to silence warning
6667
}
6768

6869
{
69-
ImageType * pointer = ReturnSmartPointer();
7070
// This crashes the program because though the function returned a ::Pointer, it was not stored
7171
// anywhere so the reference count was not increased, so it got deleted.
72+
73+
// ImageType * pointer = ReturnSmartPointer();
7274
// std::cout << pointer->GetLargestPossibleRegion() << std::endl;
73-
pointer = nullptr; // Here to silence warning
7475
}
7576

7677
{
7778
// I thought this might also work, but it does not (crash).
7879
// My reasoning was that even though you don't return a smart pointer, you assign the object to a smart
7980
// pointer at return time, so it still has a reference count of 1.
81+
8082
// ImageType::Pointer smartPointer = ReturnPointer(); // this line causes a 'glibc error'
8183
// std::cout << smartPointer->GetLargestPossibleRegion() << std::endl;
8284
}

src/Core/Mesh/AccessDataInCells/Code.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ main(int, char *[])
7575

7676
while (cellDataIterator != end)
7777
{
78-
PixelType cellValue = cellDataIterator.Value();
79-
// std::cout << cellValue << std::endl; //same values as before
78+
const auto cellValue = cellDataIterator.Value();
79+
std::cout << cellValue << std::endl; // same values as before
8080
++cellDataIterator;
8181
}
8282

0 commit comments

Comments
 (0)