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

--- Comment #11 from anlauf at gcc dot gnu.org ---
(In reply to Sam James from comment #9)
> A handful more:
> ```
> In function ‘gfc_restore_backend_locus’,
>     inlined from ‘gfc_trans_if_1’ at
> /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/fortran/
> trans-stmt.cc:1485:31:
> /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/fortran/
> trans.cc:2323:39: warning: ‘saved_loc.lb’ may be used uninitialized
> [-Wmaybe-uninitialized]
>  2323 |   gfc_current_backend_file = loc->lb->file;
>       |                                       ^
> /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/fortran/
> trans-stmt.cc: In function ‘gfc_trans_if_1’:
> /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/fortran/
> trans-stmt.cc:1464:9: note: ‘saved_loc.lb’ was declared here
>  1464 |   locus saved_loc;
>       |         ^

This one is a false-positive. The code in question is:

  if (code->expr1->where.lb)
    {
      gfc_save_backend_locus (&saved_loc);
      gfc_set_backend_locus (&code->expr1->where);
    }

  gfc_conv_expr_val (&if_se, code->expr1);

  if (code->expr1->where.lb)
    gfc_restore_backend_locus (&saved_loc);

Maybe LTO does not understand that gfc_conv_expr_val (my guess) does not have
a side-effect that changes the condition (code->expr1->where.lb != NULL).


> /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/fortran/
> parse.cc: In function ‘parse_contained’:
> /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/fortran/
> parse.cc:6578:15: warning: ‘sym’ may be used uninitialized
> [-Wmaybe-uninitialized]
>  6578 |           if (!sym->attr.pure)
>       |               ^
> /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/fortran/
> parse.cc:6507:15: note: ‘sym’ was declared here
>  6507 |   gfc_symbol *sym;
>       |               ^

That could be solved by initializing sym.

> /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/fortran/
> match.cc: In function ‘gfc_match_call’:
> /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/fortran/
> match.cc:5132:33: warning: ‘select_st’ may be used uninitialized
> [-Wmaybe-uninitialized]
>  5132 |       select_sym = select_st->n.sym;                                
> |                                 ^
> /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/fortran/
> match.cc:5124:20: note: ‘select_st’ declared here
>  5124 |       gfc_symtree *select_st;
>       |                    ^

That's again because gfc_get_ha_sym_tree is complicated and can be fixed
by initializing select_st.

Reply via email to