https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108126
Bug ID: 108126 Summary: rust meets cppcheck Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rust Assignee: unassigned at gcc dot gnu.org Reporter: dcb314 at hotmail dot com CC: dkm at gcc dot gnu.org, gcc-rust at gcc dot gnu.org Target Milestone: --- I just ran the C/C++ static analyser over the new source code of rust. First the errors: trunk.d1/gcc/rust/ast/rust-cond-compilation.h:228:65: error: Member variable 'cfg_attrs' is initialized by itself. [selfInitialization] trunk.d1/gcc/rust/typecheck/rust-tyty.h:1635:46: error: Reference to local variable returned. [returnReference] trunk.d1/gcc/rust/typecheck/rust-tyty.h:1636:58: error: Reference to local variable returned. [returnReference] trunk.d1/gcc/rust/typecheck/rust-tyty.h:558:58: error: Reference to local variable returned. [returnReference] trunk.d1/gcc/rust/util/rust-optional.h:157:12: error: Reference to local variable returned. [returnReference] Next, the warnings: trunk.d1/gcc/rust/parse/rust-parse-impl.h:12423:21: warning: Access of moved variable 'outer_attrs'. [accessMoved] trunk.d1/gcc/rust/typecheck/rust-tyty-rules.h:394:7: warning: Class 'BaseRules' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor] trunk.d1/gcc/rust/typecheck/rust-tyty-rules.h:394:7: warning: Class 'BaseRules' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq] trunk.d1/gcc/rust/typecheck/rust-substitution-mapper.h:146:7: warning: Class 'SubstMapper' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor] trunk.d1/gcc/rust/typecheck/rust-substitution-mapper.h:146:7: warning: Class 'SubstMapper' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq] trunk.d1/gcc/rust/typecheck/rust-substitution-mapper.h:261:7: warning: Class 'SubstMapperInternal' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor] trunk.d1/gcc/rust/typecheck/rust-substitution-mapper.h:261:7: warning: Class 'SubstMapperInternal' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq] trunk.d1/gcc/rust/typecheck/rust-tyty-call.h:75:7: warning: Class 'TypeCheckCallExpr' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor] trunk.d1/gcc/rust/typecheck/rust-tyty-call.h:75:7: warning: Class 'TypeCheckCallExpr' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq] trunk.d1/gcc/rust/typecheck/rust-hir-type-check-struct.cc:29:5: warning: Class 'TypeCheckStructExpr' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor] trunk.d1/gcc/rust/typecheck/rust-hir-type-check-struct.cc:29:5: warning: Class 'TypeCheckStructExpr' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq] trunk.d1/gcc/rust/typecheck/rust-tyty.h:664:9: warning: Either the condition 'argument!=nullptr' is redundant or there is possible null pointer dereference: argument. [nullPointerRedundantCheck] trunk.d1/gcc/rust/typecheck/rust-tyty.h:740:29: warning: Either the condition 'index>mappings.size()' is redundant or 'index' can have the value mappings.size(). Expression 'mappings.at(index)' cause access out of bounds. [containerOutOfBounds] trunk.d1/gcc/rust/expand/rust-macro-substitute-ctx.cc:77:25: warning: Either the condition 'it==fragments.end()' is redundant or there is possible dereference of an invalid iterator: it. [derefInvalidIteratorRedundantCheck] trunk.d1/gcc/rust/backend/rust-tree.cc:155:5: warning: Label 'CASE_CONVERT' is not used. Should this be a 'case' of the enclosing switch()? [unusedLabelSwitch] trunk.d1/gcc/rust/backend/rust-tree.cc:45:5: warning: Label 'CASE_CONVERT' is not used. Should this be a 'case' of the enclosing switch()? [unusedLabelSwitch] trunk.d1/gcc/rust/ast/rust-expr.h:1853:3: warning: Member variable 'CallExpr::fndeclRef' is not initialized in the constructor. [uninitMemberVar] trunk.d1/gcc/rust/ast/rust-expr.h:1862:3: warning: Member variable 'CallExpr::fndeclRef' is not initialized in the copy constructor. [uninitMemberVar] trunk.d1/gcc/rust/util/rust-canonical-path.h:51:18: warning: Member variable 'CanonicalPath::crate_num' is not assigned a value in 'CanonicalPath::operator='. [operatorEqVarError] trunk.d1/gcc/rust/util/rust-canonical-path.h:49:3: warning: Member variable 'CanonicalPath::crate_num' is not initialized in the copy constructor. [uninitMemberVar] trunk.d1/gcc/rust/ast/rust-stmt.h:112:12: warning: Member variable 'LetStmt::inferedType' is not assigned a value in 'LetStmt::operator='. [operatorEqVarError] trunk.d1/gcc/rust/ast/rust-stmt.h:88:3: warning: Member variable 'LetStmt::inferedType' is not initialized in the constructor. [uninitMemberVar] trunk.d1/gcc/rust/ast/rust-stmt.h:97:3: warning: Member variable 'LetStmt::inferedType' is not initialized in the copy constructor. [uninitMemberVar] trunk.d1/gcc/rust/lex/rust-lex.cc:119:8: warning: Member variable 'Lexer::current_char' is not initialized in the constructor. [uninitMemberVar] trunk.d1/gcc/rust/lex/rust-lex.cc:125:8: warning: Member variable 'Lexer::current_char' is not initialized in the constructor. [uninitMemberVar] trunk.d1/gcc/rust/rust-session-manager.h:286:3: warning: Member variable 'Session::backend' is not initialized in the constructor. [uninitMemberVar] trunk.d1/gcc/rust/rust-session-manager.h:286:3: warning: Member variable 'Session::linemap' is not initialized in the constructor. [uninitMemberVar] trunk.d1/gcc/rust/rust-session-manager.h:286:3: warning: Member variable 'Session::mappings' is not initialized in the constructor. [uninitMemberVar] trunk.d1/gcc/rust/typecheck/rust-hir-type-check-struct.cc:27:22: warning: Member variable 'TypeCheckStructExpr::resolved_field_value_expr' is not initialized in the constructor. [uninitMemberVarPrivate] trunk.d1/gcc/rust/util/rust-hir-map.cc:411:4: warning: Possible null pointer dereference: parent_block [nullPointer] trunk.d1/gcc/rust/ast/rust-ast.h:1211:10: warning: The class 'Lifetime' defines member variable with name 'node_id' also defined in its parent class 'TypeParamBound'. [duplInheritedMember] trunk.d1/gcc/rust/ast/rust-macro.h:565:10: warning: The class 'MacroInvocation' defines member variable with name 'node_id' also defined in its parent class 'Expr'. [duplInheritedMember] trunk.d1/gcc/rust/ast/rust-macro.h:565:10: warning: The class 'MacroInvocation' defines member variable with name 'node_id' also defined in its parent class 'ExternalItem'. [duplInheritedMember] trunk.d1/gcc/rust/ast/rust-macro.h:565:10: warning: The class 'MacroInvocation' defines member variable with name 'node_id' also defined in its parent class 'Stmt'. [duplInheritedMember] trunk.d1/gcc/rust/ast/rust-macro.h:565:10: warning: The class 'MacroInvocation' defines member variable with name 'node_id' also defined in its parent class 'TraitItem'. [duplInheritedMember] trunk.d1/gcc/rust/ast/rust-macro.h:565:10: warning: The class 'MacroInvocation' defines member variable with name 'node_id' also defined in its parent class 'Type'. [duplInheritedMember] trunk.d1/gcc/rust/checks/lints/rust-lint-marklive.h:292:23: warning: The class 'MarkLive' defines member variable with name 'mappings' also defined in its parent class 'MarkLiveBase'. [duplInheritedMember] trunk.d1/gcc/rust/checks/lints/rust-lint-scan-deadcode.h:137:23: warning: The class 'ScanDeadcode' defines member variable with name 'mappings' also defined in its parent class 'MarkLiveBase'. [duplInheritedMember] There were over 350 style warnings, most for lack of use of STL, but I noticed these two: trunk.d1/gcc/rust/resolve/rust-ast-resolve-type.cc:536:15: style: Redundant condition: !is_type. 'is_type || (!is_type && !is_value)' is equivalent to 'is_type || !is_value' [redundantCondition] trunk.d1/gcc/rust/typecheck/rust-hir-type-check-expr.cc:1113:7: style: Redundant condition: loop_context_type->get_kind()==TyTy::TypeKind::INFER. 'A || (!A && B)' is equivalent to 'A || B' [redundantCondition] There were about 140 performance warnings, mostly about preferring parameter passing by const reference. Full lists for all these various possible problems are available on request. -- You are receiving this mail because: You are on the CC list for the bug. -- Gcc-rust mailing list Gcc-rust@gcc.gnu.org https://gcc.gnu.org/mailman/listinfo/gcc-rust