This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

False positive or bug in fortran/decl.c ?


Hi guys,

a FreeBSD reported the following via the FreeBSD bug tracker:

<<<<<<<< snip <<<<<<<<
gcc-6.1.0/gcc/fortran/decl.c has code has code of the structure:

static bool
add_hidden_procptr_result (gfc_symbol *sym)
{
  bool case1,case2;
 
  if (gfc_notification_std (GFC_STD_F2003) == ERROR)
    return false;
 
  /* First usage case: PROCEDURE and EXTERNAL statements.  */
  case1 = gfc_current_state () == COMP_FUNCTION && gfc_current_block ()
          && strcmp (gfc_current_block ()->name, sym->name) == 0
          && sym->attr.external;
  /* Second usage case: INTERFACE statements.  */
  case2 = gfc_current_state () == COMP_INTERFACE && 
gfc_state_stack->previous
          && gfc_state_stack->previous->state == COMP_FUNCTION
          && strcmp (gfc_state_stack->previous->sym->name, sym->name) == 
0;
 
  if (case1 || case2)
    {
      gfc_symtree *stree;
      if (case1)
        gfc_get_sym_tree ("ppr@", gfc_current_ns, &stree, false);
      else if (case2)
        {
          gfc_symtree *st2;
          gfc_get_sym_tree ("ppr@", gfc_current_ns->parent, &stree, 
false);
          st2 = gfc_new_symtree (&gfc_current_ns->sym_root, "ppr@");
          st2->n.sym = stree->n.sym;
        }

The compiler used to compile lang/gcc6 complained about stree not being 
initialized (when both parts of the if. . .else if. . . were not executed.

The code would be less likely to produce the false positive if the "if 
(case2)" was not code: just use an else instead, possibly with a case2 
comment.
>>>>>>>> snap >>>>>>>>

That report is at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210828 
and I'll close this after sending this e-mail since that's the wrong 
venue, but I hope it may be useful for you.

Gerald


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]