public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104330] New: ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294
@ 2022-02-01 17:39 gscfq@t-online.de
  2022-02-01 21:05 ` [Bug fortran/104330] " gscfq@t-online.de
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gscfq@t-online.de @ 2022-02-01 17:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104330
           Summary: ICE in gfc_simplify_image_index, at
                    fortran/simplify.cc:8294
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Affects versions down to at least r5 :
(with -fcoarray=single and -fcoarray=lib)


$ cat z1.f90
program p
   type t
   end type
   class(t), allocatable :: x[:]
   allocate (t :: x[*])
   print *, image_index(x, [1])
end


$ cat z2.f90
program p
   class(*), allocatable :: x[:]
   allocate (t :: x[*])
   print *, image_index(x, [1])
end


$ cat z3.f90   # accepted with type
program p
   type t
   end type
   type(t), allocatable :: x[:]
   allocate (t :: x[*])
   print *, image_index(x, [1])
end


$ gfortran-12-20220130 -c z3.f90 -fcoarray=lib
$
$ gfortran-12-20220130 -c z1.f90 -fcoarray=lib
f951: internal compiler error: Segmentation fault
0xcc655f crash_signal
        ../../gcc/toplev.cc:322
0x787eed gfc_simplify_image_index(gfc_expr*, gfc_expr*)
        ../../gcc/fortran/simplify.cc:8294
0x702736 do_simplify
        ../../gcc/fortran/intrinsic.cc:4669
0x70d64a gfc_intrinsic_func_interface(gfc_expr*, int)
        ../../gcc/fortran/intrinsic.cc:5055
0x7619c8 resolve_unknown_f
        ../../gcc/fortran/resolve.cc:2972
0x7619c8 resolve_function
        ../../gcc/fortran/resolve.cc:3329
0x7619c8 gfc_resolve_expr(gfc_expr*)
        ../../gcc/fortran/resolve.cc:7169
0x767db4 gfc_resolve_expr(gfc_expr*)
        ../../gcc/fortran/resolve.cc:7136
0x767db4 gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.cc:11928
0x76676f gfc_resolve_blocks(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.cc:10944
0x766ac8 gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.cc:11918
0x769407 resolve_codes
        ../../gcc/fortran/resolve.cc:17537
0x7694ce gfc_resolve(gfc_namespace*)
        ../../gcc/fortran/resolve.cc:17572
0x7517f4 resolve_all_program_units
        ../../gcc/fortran/parse.cc:6586
0x7517f4 gfc_parse_file()
        ../../gcc/fortran/parse.cc:6842
0x79eecf gfc_be_parse_file
        ../../gcc/fortran/f95-lang.cc:216

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/104330] ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294
  2022-02-01 17:39 [Bug fortran/104330] New: ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294 gscfq@t-online.de
@ 2022-02-01 21:05 ` gscfq@t-online.de
  2022-05-25 18:45 ` kargl at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: gscfq@t-online.de @ 2022-02-01 21:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from G. Steinmetz <gscfq@t-online.de> ---

Better test cases (valid) instead of accidentally invalid z2.f90 :


$ cat zz4.f90
program p
   class(*), allocatable :: x[:]
   allocate (real :: x[*])
   print *, image_index(x, [1])
end


$ cat zz5.f90
program p
   class(*), allocatable :: x[:,:]
   allocate (real :: x[8,*])
   print *, image_index(x, [5,3])
end


$ cat zz7.f90
program p
   type t
   end type
   class(*), allocatable :: x[:,:,:]
   allocate (t :: x[8,8,*])
   print *, image_index(x, [3,2,1])
end

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/104330] ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294
  2022-02-01 17:39 [Bug fortran/104330] New: ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294 gscfq@t-online.de
  2022-02-01 21:05 ` [Bug fortran/104330] " gscfq@t-online.de
@ 2022-05-25 18:45 ` kargl at gcc dot gnu.org
  2022-10-17 20:24 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-05-25 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |kargl at gcc dot gnu.org
   Last reconfirmed|                            |2022-05-25

--- Comment #2 from kargl at gcc dot gnu.org ---
NULL pointer dereference.  This fixes the ICE.  Don't know if the compiled code
is correct.  I don't have CLASS in my codes.

diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index 233cc42137f..542c8cb5537 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -8295,7 +8295,7 @@ gfc_simplify_image_index (gfc_expr *coarray, gfc_expr
*sub)
     if (ref->type == REF_COMPONENT)
       as = ref->u.ar.as;

-  if (as->type == AS_DEFERRED)
+  if (!as || as->type == AS_DEFERRED)
     return NULL;

   /* "valid sequence of cosubscripts" are required; thus, return 0 unless

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/104330] ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294
  2022-02-01 17:39 [Bug fortran/104330] New: ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294 gscfq@t-online.de
  2022-02-01 21:05 ` [Bug fortran/104330] " gscfq@t-online.de
  2022-05-25 18:45 ` kargl at gcc dot gnu.org
@ 2022-10-17 20:24 ` anlauf at gcc dot gnu.org
  2022-10-17 20:44 ` sgk at troutmask dot apl.washington.edu
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-10-17 20:24 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #2)
> NULL pointer dereference.  This fixes the ICE.  Don't know if the compiled
> code is correct.  I don't have CLASS in my codes.
> 
> diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
> index 233cc42137f..542c8cb5537 100644
> --- a/gcc/fortran/simplify.cc
> +++ b/gcc/fortran/simplify.cc
> @@ -8295,7 +8295,7 @@ gfc_simplify_image_index (gfc_expr *coarray, gfc_expr
> *sub)
>      if (ref->type == REF_COMPONENT)
>        as = ref->u.ar.as;
>  
> -  if (as->type == AS_DEFERRED)
> +  if (!as || as->type == AS_DEFERRED)
>      return NULL;
>  
>    /* "valid sequence of cosubscripts" are required; thus, return 0 unless

Steve,

I think it is obvious that we cannot simplify IMAGE_INDEX here.
If you don't object, I will commit your fix for you as obvious.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/104330] ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294
  2022-02-01 17:39 [Bug fortran/104330] New: ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-10-17 20:24 ` anlauf at gcc dot gnu.org
@ 2022-10-17 20:44 ` sgk at troutmask dot apl.washington.edu
  2022-10-17 20:47 ` cvs-commit at gcc dot gnu.org
  2022-10-17 20:49 ` anlauf at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2022-10-17 20:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Mon, Oct 17, 2022 at 08:24:36PM +0000, anlauf at gcc dot gnu.org wrote:
> 
> Steve,
> 
> I think it is obvious that we cannot simplify IMAGE_INDEX here.
> If you don't object, I will commit your fix for you as obvious.
> 

No objection.  Feel free to grab anything I post in bugzilla
and use it as you see fit.

You need not include me the ChangeLog as co-author unless
you want people to yell at me instead of you. :-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/104330] ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294
  2022-02-01 17:39 [Bug fortran/104330] New: ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-10-17 20:44 ` sgk at troutmask dot apl.washington.edu
@ 2022-10-17 20:47 ` cvs-commit at gcc dot gnu.org
  2022-10-17 20:49 ` anlauf at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-17 20:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:84807af0ca6dfdb81abb8e925ce32acbcab29868

commit r13-3342-g84807af0ca6dfdb81abb8e925ce32acbcab29868
Author: Steve Kargl <kargl@gcc.gnu.org>
Date:   Mon Oct 17 22:42:40 2022 +0200

    Fortran: NULL pointer dereference in gfc_simplify_image_index [PR104330]

    gcc/fortran/ChangeLog:

            PR fortran/104330
            * simplify.cc (gfc_simplify_image_index): Do not dereference NULL
            pointer.

    gcc/testsuite/ChangeLog:

            PR fortran/104330
            * gfortran.dg/pr104330.f90: New test.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/104330] ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294
  2022-02-01 17:39 [Bug fortran/104330] New: ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-10-17 20:47 ` cvs-commit at gcc dot gnu.org
@ 2022-10-17 20:49 ` anlauf at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-10-17 20:49 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #6 from anlauf at gcc dot gnu.org ---
(In reply to Steve Kargl from comment #4)
> You need not include me the ChangeLog as co-author unless
> you want people to yell at me instead of you. :-)

Well, if you ask me, it's better they yell at you than at me... ;-)

So pushed under your name.

Thanks for your patch, btw.

And thanks to Gerhard, sort of.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-17 20:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01 17:39 [Bug fortran/104330] New: ICE in gfc_simplify_image_index, at fortran/simplify.cc:8294 gscfq@t-online.de
2022-02-01 21:05 ` [Bug fortran/104330] " gscfq@t-online.de
2022-05-25 18:45 ` kargl at gcc dot gnu.org
2022-10-17 20:24 ` anlauf at gcc dot gnu.org
2022-10-17 20:44 ` sgk at troutmask dot apl.washington.edu
2022-10-17 20:47 ` cvs-commit at gcc dot gnu.org
2022-10-17 20:49 ` anlauf at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).