public inbox for gcc-rust@gcc.gnu.org
 help / color / mirror / Atom feed
* [Bug rust/108126] New: rust meets cppcheck
@ 2022-12-15 11:31 dcb314 at hotmail dot com
  2022-12-15 11:49 ` [Bug rust/108126] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dcb314 at hotmail dot com @ 2022-12-15 11:31 UTC (permalink / raw)
  To: gcc-rust

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug rust/108126] rust meets cppcheck
  2022-12-15 11:31 [Bug rust/108126] New: rust meets cppcheck dcb314 at hotmail dot com
@ 2022-12-15 11:49 ` redi at gcc dot gnu.org
  2022-12-15 11:51 ` redi at gcc dot gnu.org
  2022-12-15 14:13 ` egallager at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-12-15 11:49 UTC (permalink / raw)
  To: gcc-rust

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108126

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=108111

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug rust/108126] rust meets cppcheck
  2022-12-15 11:31 [Bug rust/108126] New: rust meets cppcheck dcb314 at hotmail dot com
  2022-12-15 11:49 ` [Bug rust/108126] " redi at gcc dot gnu.org
@ 2022-12-15 11:51 ` redi at gcc dot gnu.org
  2022-12-15 14:13 ` egallager at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2022-12-15 11:51 UTC (permalink / raw)
  To: gcc-rust

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108126

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-12-15
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug rust/108126] rust meets cppcheck
  2022-12-15 11:31 [Bug rust/108126] New: rust meets cppcheck dcb314 at hotmail dot com
  2022-12-15 11:49 ` [Bug rust/108126] " redi at gcc dot gnu.org
  2022-12-15 11:51 ` redi at gcc dot gnu.org
@ 2022-12-15 14:13 ` egallager at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: egallager at gcc dot gnu.org @ 2022-12-15 14:13 UTC (permalink / raw)
  To: gcc-rust

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108126

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org
           Keywords|                            |diagnostic
             Blocks|                            |89863


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89863
[Bug 89863] [meta-bug] Issues in gcc that other static analyzers (cppcheck,
clang-static-analyzer, PVS-studio) find that gcc misses
-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-15 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 11:31 [Bug rust/108126] New: rust meets cppcheck dcb314 at hotmail dot com
2022-12-15 11:49 ` [Bug rust/108126] " redi at gcc dot gnu.org
2022-12-15 11:51 ` redi at gcc dot gnu.org
2022-12-15 14:13 ` egallager at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).