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

            Bug ID: 99616
           Summary: gcc/cp/decl.c:12220: pointless test ?
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

cppcheck says:

trunk.git/gcc/cp/decl.c:12214:15: warning: Either the condition
'declarator==NULL' is redundant or there is possible null pointer dereference:
declarator. [nullPointerRedundantCheck]
trunk.git/gcc/cp/decl.c:12222:8: warning: Either the condition
'declarator==NULL' is redundant or there is possible null pointer dereference:
declarator. [nullPointerRedundantCheck]
trunk.git/gcc/cp/decl.c:12224:8: warning: Either the condition
'declarator==NULL' is redundant or there is possible null pointer dereference:
declarator. [nullPointerRedundantCheck]

Since

  for (; declarator; declarator = declarator->declarator)

then this looks redundant:

          if (declarator == NULL || declarator->kind == cdk_id)

Maybe better code

          if (declarator->kind == cdk_id)

Reply via email to