mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
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:
@@ -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. |
|
||||
|
||||
@@ -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]
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user