From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 62B44382FAD3; Thu, 15 Dec 2022 11:31:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62B44382FAD3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671103864; bh=No/ILnchdHXgalRR5LCDPyAiJxuJgu8C8OgD3D/Y55E=; h=From:To:Subject:Date:From; b=cUn5Nfs/ZiHtSvvBH629rgotJhTT0Oe5pMLiizn73lzhHZ6R/Iqcq3Ez1aVdnIck7 0vE/8aiKlHiTw3N/VnGLPWRHEe0GsoDjo6putnD6PHAf0LG7xuNAL6vuy00sS+xUS0 hSsNuAGSuuj0rL/lc4NzcbRZi8jJM1l7UllNxVok= From: "dcb314 at hotmail dot com" To: gcc-rust@gcc.gnu.org Subject: [Bug rust/108126] New: rust meets cppcheck Date: Thu, 15 Dec 2022 11:31:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rust X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dcb314 at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108126 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 'BaseRu= les' 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 'BaseRu= les' does not have a operator=3D 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=3D 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=3D which is recommended sinc= e 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 s= ince 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=3D 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: Cl= ass '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: Cl= ass 'TypeCheckStructExpr' does not have a operator=3D which is recommended sinc= e it has dynamic memory/resource allocation(s). [noOperatorEq] trunk.d1/gcc/rust/typecheck/rust-tyty.h:664:9: warning: Either the condition 'argument!=3Dnullptr' is redundant or there is possible null pointer derefe= rence: argument. [nullPointerRedundantCheck] trunk.d1/gcc/rust/typecheck/rust-tyty.h:740:29: warning: Either the conditi= on '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=3D=3Dfragments.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. [uninitMemberV= ar] 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=3D'. [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=3D'. [operatorEqVarError] trunk.d1/gcc/rust/ast/rust-stmt.h:88:3: warning: Member variable 'LetStmt::inferedType' is not initialized in the constructor. [uninitMember= Var] 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. [uninitMemberV= ar] trunk.d1/gcc/rust/lex/rust-lex.cc:125:8: warning: Member variable 'Lexer::current_char' is not initialized in the constructor. [uninitMemberV= ar] 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' def= ines 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 'MacroInvocat= ion' 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 'MacroInvocat= ion' 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 'MacroInvocat= ion' 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 'MacroInvocat= ion' 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 'MacroInvocat= ion' 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 cl= ass '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: T= he class 'ScanDeadcode' defines member variable with name 'mappings' also defi= ned in its parent class 'MarkLiveBase'. [duplInheritedMember] There were over 350 style warnings, most for lack of use of STL, but I noti= ced 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()=3D=3DTyTy::TypeKind::INF= ER. '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. --=20 You are receiving this mail because: You are on the CC list for the bug.=