Skip to content

Commit

Permalink
Ticket 11403: Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitcowboy committed Aug 9, 2024
1 parent 9c3c0ed commit 096b91c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5178,3 +5178,30 @@ struct S_std_as_const { // #12974
}
std::list<int> l;
};

void containerOutOfBounds_std_string(std::string &var) { // #11403
std::string s0{"x"};
// cppcheck-suppress containerOutOfBounds
var+= s0[2];

std::string s1{ R"(x)" };
// cppcheck-suppress containerOutOfBounds
var+= s1[2];

std::string s2 = R"--(XYZ)--";
// cppcheck-suppress containerOutOfBounds
var+= s2[3];

std::string s3 = {R"--(XYZ)--"};
// cppcheck-suppress containerOutOfBounds
var+= s3[3];

const char *x = R"--(XYZ)--";
std::string s4(x);
// TODO cppcheck-suppress containerOutOfBounds
var+= s4[3];

std::string s5{x};
// TODO cppcheck-suppress containerOutOfBounds
var+= s5[3];
}

0 comments on commit 096b91c

Please sign in to comment.