diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 304319505..d3b17b1ac 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1462,6 +1462,9 @@ bool CheckUninitVar::checkLoopBody(const Token *tok, const Variable& var, const } } + if (Token::Match(tok, "sizeof|typeof (")) + tok = tok->next()->link(); + if (Token::Match(tok, "asm ( %str% ) ;")) return true; } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 776010083..1d4fac0bc 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2812,6 +2812,13 @@ private: " }\n" "}"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar2("static void f(void) {\n" + " struct ABC *abc;\n" + " for (i = 0; i < 10; i++)\n" + " x += sizeof(*abc);\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void uninitvar2_4494() {