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

            Bug ID: 99615
           Summary: gcc/cp/decl.c:10038:possible null pointer dereference
           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:10038:7: warning: Either the condition 'attrlist' is
redundant or there is possible null pointer dereference: attrlist.
[nullPointerRedundantCheck]

Source code is

  decl = check_explicit_specialization (orig_declarator, decl,
                                        template_count,
                                        2 * funcdef_flag +
                                        4 * (friendp != 0) +
                                        8 * concept_p,
                                        *attrlist);
  if (decl == error_mark_node)
    return NULL_TREE;

  if (DECL_STATIC_FUNCTION_P (decl))
    check_static_quals (decl, quals);

  if (attrlist)
    {
      cplus_decl_attributes (&decl, *attrlist, 0);
      *attrlist = NULL_TREE;
    }

Note how the variable attrlist is used as a pointer, *before*
it is later checked.

Another possibility is that the final if statement should be

  if (*attrlist)

Reply via email to