#include <stdlib.h> void f(const char* s) { wchar_t buf[99]; mbstowcs(buf, s, 99); } t.c:6:14: error: Uninitialized variable: buf [uninitvar]
Still happens with current main branch. Use --enable=all.
struct S { enum class E { e1, e2 }; E e; char* e1; }; void f(S& s) { s.e = S::E::e1; } t.cpp:7:6: portability: Assigning a pointer to an integer is not portable. [AssignmentAddressToInteger]
It seems like 'not' isn't getting recognized here. Tricky to reproduce, it has to be in a const member function. struct C { void f(int i) const { bool done = false; if (i == 0) done = true; if (not done) { } } }; t.cpp:4:8: style: The scope of the variable 'done' can be reduced. [variableScope] t.cpp:4:13: style: Variable 'done' is assigned a value that is never used. [unreadVariable] t.cpp:6:9: style: Variable 'done' is assigned a value that is never used. [unreadVariable]
Regression since 1.90: void g1(); void g2(); void g3(); void f() { bool b = false; try { g1(); b = true; g2(); } catch (...) { if (b) { g3(); } } } t.cpp:13:7: note: Condition 'b' is always true
Might have something to do with unsigned expanding to unsigned int, as casting to int works as expected. void f(unsigned x) { printf("%d", int(x)); }
void f(int x) { printf("%u", (unsigned)x); printf("%u", unsigned(x)); } cppcheck --enable=warning --language=c++ t.cpp elicits [t.cpp:4]: (warning) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'int' for line 4 but not for line 3.