Skip to content

Commit 702a29c

Browse files
author
Your Name
committed
Add another test
1 parent 47b4555 commit 702a29c

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/teststl.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,6 +2557,17 @@ class TestStl : public TestFixture {
25572557
ASSERT_EQUALS("[test.cpp:5:37]: (error) The algorithm 'std::copy' accesses 5 elements through the iterator 'it' but only 3 elements are available. [algorithmOutOfBounds]\n",
25582558
errout_str());
25592559

2560+
// ..and the size is the size at the call, not at the creation of the iterator
2561+
check("void f() {\n"
2562+
" const std::vector<int> v0{1,2,3,4,5};\n"
2563+
" std::list<int> l1(10);\n"
2564+
" auto it = l1.begin();\n"
2565+
" l1.resize(3);\n"
2566+
" std::copy(v0.begin(), v0.end(), it);\n"
2567+
"}\n");
2568+
ASSERT_EQUALS("[test.cpp:6:37]: (error) The algorithm 'std::copy' accesses 5 elements through the iterator 'it' but only 3 elements are available. [algorithmOutOfBounds]\n",
2569+
errout_str());
2570+
25602571
// conditional container size
25612572
check("void f(std::vector<int>& v) {\n"
25622573
" const std::vector<int> v0{1,2,3,4,5};\n"

0 commit comments

Comments
 (0)