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

Method cstyleCastError

lib/checkother.cpp:397–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395}
396
397void CheckOtherImpl::cstyleCastError(const Token *tok, bool isPtr)
398{
399 const std::string type = isPtr ? "pointer" : "reference";
400 reportError(tok, Severity::style, "cstyleCast",
401 "C-style " + type + " casting\n"
402 "C-style " + type + " casting detected. C++ offers four different kinds of casts as replacements: "
403 "static_cast, const_cast, dynamic_cast and reinterpret_cast. A C-style cast could evaluate to "
404 "any of those automatically, thus it is considered safer if the programmer explicitly states "
405 "which kind of cast is expected.", CWE398, Certainty::normal);
406}
407
408void CheckOtherImpl::warningDangerousTypeCast()
409{

Callers 1

getErrorMessagesMethod · 0.80

Calls 1

reportErrorFunction · 0.70

Tested by

no test coverage detected