$ bin/cppcheck /tmp/m.c++ Checking /tmp/m.c++ ... /tmp/m.c++:13:40: warning: Uninitialized variable: i [uninitvar] for (size_t j = 0; j < i; j++) { ^
$ cat /tmp/m.c++
int main() { size_t i, n_elements= 5; std::string *p = new std::string[n_elements]; try { for (i = 0; i < n_elements; i++) { new(p) std::string; ++p; } } catch (...) { for (size_t j = 0; j < i; j++) { --p; }
throw; }
}
"i" will always be initialized in the try clause.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11492
Thanks for fixing.
Log in to post a comment.
$ bin/cppcheck /tmp/m.c++
Checking /tmp/m.c++ ...
/tmp/m.c++:13:40: warning: Uninitialized variable: i [uninitvar]
for (size_t j = 0; j < i; j++) {
^
$ cat /tmp/m.c++
include <string></string>
int main()
{
size_t i, n_elements= 5;
std::string *p = new std::string[n_elements];
try {
for (i = 0; i < n_elements; i++) {
new(p) std::string;
++p;
}
} catch (...) {
for (size_t j = 0; j < i; j++) {
--p;
}
}
"i" will always be initialized in the try clause.
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11492
Thanks for fixing.