MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / valueFlowUninitForLoop

Method valueFlowUninitForLoop

test/testuninitvar.cpp:7834–7852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7832 }
7833
7834 void valueFlowUninitForLoop()
7835 {
7836 valueFlowUninit("void f() {\n" // #9924
7837 " for (unsigned int a = 0, b; a < 42; a++) {\n"
7838 " std::cout << ++b << std::endl;\n"
7839 " }\n"
7840 "}\n");
7841 ASSERT_EQUALS("[test.cpp:3:24]: (error) Uninitialized variable: b [uninitvar]\n", errout_str());
7842
7843 // #14137
7844 valueFlowUninit("int f(int n) {\n"
7845 " int x;\n"
7846 " assert(n > 0);\n"
7847 " for(int i=0;i<n;i++)\n"
7848 " x = n;\n"
7849 " return x;\n"
7850 "}\n");
7851 ASSERT_EQUALS("", errout_str());
7852 }
7853
7854 void uninitvar_memberfunction() {
7855 // # 8715

Callers

nothing calls this directly

Calls 1

valueFlowUninitFunction · 0.85

Tested by

no test coverage detected