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

Method noConstructorError

lib/checkclass.cpp:1157–1163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1155}
1156
1157void CheckClassImpl::noConstructorError(const Token *tok, const std::string &classname, bool isStruct)
1158{
1159 // For performance reasons the constructor might be intentionally missing. Therefore this is not a "warning"
1160 const std::string message {"The " + std::string(isStruct ? "struct" : "class") + " '$symbol' does not declare a constructor although it has private member variables which likely require initialization."};
1161 const std::string verbose {message + " Member variables of native types, pointers, or references are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior."};
1162 reportError(tok, Severity::style, "noConstructor", "$symbol:" + classname + '\n' + message + '\n' + verbose, CWE398, Certainty::normal);
1163}
1164
1165void CheckClassImpl::noExplicitConstructorError(const Token *tok, const std::string &classname, bool isStruct)
1166{

Callers 1

getErrorMessagesMethod · 0.80

Calls 1

reportErrorFunction · 0.70

Tested by

no test coverage detected