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

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Sep 01, 2022 at 06:45:25PM +0000, anlauf at gcc dot gnu.org wrote:
>
> Alternatively, simply catching the NULL pointer dereference by
> 
> diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
> index b6400514731..0f9b2ced4c2 100644
> --- a/gcc/fortran/decl.cc
> +++ b/gcc/fortran/decl.cc
> @@ -423,7 +423,8 @@ match_data_constant (gfc_expr **result)
>          data-pointer-initialization compatible (7.5.4.6) with the initial
>          data target; the data statement object is initially associated
>          with the target.  */
> -      if ((*result)->symtree->n.sym->attr.save
> +      if ((*result)->symtree
> +         && (*result)->symtree->n.sym->attr.save
>           && (*result)->symtree->n.sym->attr.target)
>         return m;
>        gfc_free_expr (*result);
> 
> also fixes the ICE.  It's basically that the error message generated differs
> from the one I get with your patch.
> 
> Do you have additional thoughts?
> 

Now, that I've looked at the two patches again. I think I prefer
yours or mine.  A simple NULL pointer dereference can be committed
under the "Obviously correct" rule.

Reply via email to