File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -485,8 +485,8 @@ void CheckBool::checkAssignBoolToFloat()
485485 const Scope * scope = symbolDatabase->functionScopes [i];
486486 for (const Token* tok = scope->classStart ; tok != scope->classEnd ; tok = tok->next ()) {
487487 if (Token::Match (tok, " !!* %var% = %bool% ;" )) {
488- const Variable *var = symbolDatabase->getVariableFromVarId (tok->next ()->varId ());
489- if (var->isFloatingType ())
488+ const Variable * const var = symbolDatabase->getVariableFromVarId (tok->next ()->varId ());
489+ if (var && var ->isFloatingType ())
490490 assignBoolToFloatError (tok->next ());
491491 }
492492 }
Original file line number Diff line number Diff line change @@ -155,6 +155,12 @@ class TestBool : public TestFixture {
155155 " long double d = (2>1);\n "
156156 " }" );
157157 TODO_ASSERT_EQUALS (" [test.cpp:2]: (style) Boolean value assigned to floating point variable.\n " , " " , errout.str ());
158+
159+ // stability - don't crash:
160+ check (" void foo4() {\n "
161+ " unknown = false;\n "
162+ " }" );
163+ ASSERT_EQUALS (" " , errout.str ());
158164 }
159165
160166 void comparisonOfBoolExpressionWithInt1 () {
You can’t perform that action at this time.
0 commit comments