From c59dab2738ff469e08015d2f490ca0d9ad658992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 17 Jan 2013 23:18:37 +0100 Subject: [PATCH] uninitialized struct member: changed severity from warning to error since it is UB --- lib/checkuninitvar.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 4f88345fc..bf147fccd 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1082,7 +1082,7 @@ void CheckUninitVar::checkScope(const Scope* scope) tok = tok->next(); if (stdtype || i->isPointer()) checkScopeForVariable(scope, tok, *i, NULL, NULL, NULL); - if (_settings->experimental && _settings->isEnabled("style") && Token::Match(i->typeStartToken(), "struct %type% %var% ;")) { + if (_settings->experimental && Token::Match(i->typeStartToken(), "struct %type% %var% ;")) { const std::string structname(i->typeStartToken()->next()->str()); const SymbolDatabase * symbolDatabase = _tokenizer->getSymbolDatabase(); for (std::size_t j = 0U; j < symbolDatabase->classAndStructScopes.size(); ++j) { @@ -1518,10 +1518,7 @@ void CheckUninitVar::uninitvarError(const Token *tok, const std::string &varname void CheckUninitVar::uninitStructMemberError(const Token *tok, const std::string &membername) { reportError(tok, - Severity::warning, + Severity::error, "uninitStructMember", - "Perhaps '" + membername + "' should be initialized before calling function.\n" - "The struct is not fully initialized, '" + membername + "' hasn't been initialized. " - "Using the struct in function call might be dangerous, unless you know for sure that the member " - "will not be used by the function."); + "Uninitialized struct member: " + membername); }