Merge pull request #16913 from MathiasVP/add-iterator-to-expired-container-fp-3

C++: Add `cpp/iterator-to-expired-container` FP test
This commit is contained in:
Mathias Vorreiter Pedersen
2024-07-05 16:26:08 +01:00
committed by GitHub
2 changed files with 28 additions and 1 deletions

View File

@@ -3,3 +3,4 @@
| test.cpp:702:27:702:27 | call to operator[] | This object is destroyed at the end of the full-expression. |
| test.cpp:727:23:727:23 | call to operator[] | This object is destroyed at the end of the full-expression. |
| test.cpp:735:23:735:23 | call to operator[] | This object is destroyed at the end of the full-expression. |
| test.cpp:826:25:826:43 | pointer to ~HasBeginAndEnd output argument | This object is destroyed at the end of the full-expression. |

View File

@@ -801,4 +801,30 @@ void test5(int i)
for(const auto& vs : vvs) { }
++i;
} // GOOD
}
}
struct HasBeginAndEnd
{
~HasBeginAndEnd();
using value_type = int;
using difference_type = std::ptrdiff_t;
using pointer = int*;
using reference = int&;
using iterator_category = std::random_access_iterator_tag;
std::vector<int>::iterator begin() const;
std::vector<int>::iterator end() const;
};
HasBeginAndEnd getHasBeginAndEnd();
bool getBool();
void test6()
{
while(getBool())
{
for (const int& x : getHasBeginAndEnd()) // GOOD [FALSE POSITIVE]
{
}
}
}