public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/107995] New: ICE: Segmentation fault, without backtrace
@ 2022-12-06 18:06 gscfq@t-online.de
  2022-12-10  2:19 ` [Bug fortran/107995] " kargl at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2022-12-06 18:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107995
           Summary: ICE: Segmentation fault, without backtrace
           Product: gcc
           Version: 13.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 :


$ cat z1.f90
program p
   implicit none
   integer :: n
   n(n) = 1
   print *, n(n)
end

$ cat z2.f90
program p
   n(n) = 1
   print *, n(n)
end


$ gfortran-13-20221204 -c z1.f90
z1.f90:3:15:

    3 |    integer :: n
      |               1
Error: Self-referential argument 'n' at (1) is not allowed
z1.f90:5:14:

    5 |    print *, n(n)
      |              1
Error: Statement function 'n' at (1) is not allowed as an actual argument
gfortran: internal compiler error: Segmentation fault signal terminated program
f951
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.

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

* [Bug fortran/107995] ICE: Segmentation fault, without backtrace
  2022-12-06 18:06 [Bug fortran/107995] New: ICE: Segmentation fault, without backtrace gscfq@t-online.de
@ 2022-12-10  2:19 ` kargl at gcc dot gnu.org
  2022-12-10 19:37 ` anlauf at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-12-10  2:19 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

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

--- Comment #1 from kargl at gcc dot gnu.org ---
This patch prevents the ICE.  It has been regression tested, and not regression
occurred.  AFAICT, a statement function cannot be a dummy argument.


diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc
index d3e199535b3..8f9eabf0f1c 100644
--- a/gcc/fortran/interface.cc
+++ b/gcc/fortran/interface.cc
@@ -1334,6 +1334,9 @@ gfc_check_dummy_characteristics (gfc_symbol *s1,
gfc_symbol *s2,
   if (s1 == NULL || s2 == NULL)
     return s1 == s2 ? true : false;

+  if (s1->attr.proc == PROC_ST_FUNCTION || s2->attr.proc == PROC_ST_FUNCTION)
+    return false;
+
   /* Check type and rank.  */
   if (type_must_agree)
     {

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

* [Bug fortran/107995] ICE: Segmentation fault, without backtrace
  2022-12-06 18:06 [Bug fortran/107995] New: ICE: Segmentation fault, without backtrace gscfq@t-online.de
  2022-12-10  2:19 ` [Bug fortran/107995] " kargl at gcc dot gnu.org
@ 2022-12-10 19:37 ` anlauf at gcc dot gnu.org
  2022-12-10 21:05 ` sgk at troutmask dot apl.washington.edu
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-10 19:37 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #1)
> This patch prevents the ICE.

The patch is mostly good, but does not set the errmsg variable, which
leads to garbage in the printed error message.

We could do the following (haven't found a better one yet):

diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc
index 73799c175b7..ad4182a01ae 100644
--- a/gcc/fortran/interface.cc
+++ b/gcc/fortran/interface.cc
@@ -1334,6 +1334,12 @@ gfc_check_dummy_characteristics (gfc_symbol *s1,
gfc_symbol *s2,
   if (s1 == NULL || s2 == NULL)
     return s1 == s2 ? true : false;

+  if (s1->attr.proc == PROC_ST_FUNCTION || s2->attr.proc == PROC_ST_FUNCTION)
+    {
+      strncpy (errmsg, "Statement function", err_len);
+      return false;
+    }
+
   /* Check type and rank.  */
   if (type_must_agree)
     {

This prints:

pr107995-z1.f90:4:3:

    4 |   n(n) = 1
      |   1
Error: Self-referential argument 'n' at (1) is not allowed
pr107995-z1.f90:5:13:

    5 |   print *, n(n)
      |             1
Error: Statement function 'n' at (1) is not allowed as an actual argument
pr107995-z1.f90:5:13:

    5 |   print *, n(n)
      |             1
Error: Interface mismatch in dummy procedure 'n' at (1): Statement function

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

* [Bug fortran/107995] ICE: Segmentation fault, without backtrace
  2022-12-06 18:06 [Bug fortran/107995] New: ICE: Segmentation fault, without backtrace gscfq@t-online.de
  2022-12-10  2:19 ` [Bug fortran/107995] " kargl at gcc dot gnu.org
  2022-12-10 19:37 ` anlauf at gcc dot gnu.org
@ 2022-12-10 21:05 ` sgk at troutmask dot apl.washington.edu
  2022-12-10 21:24 ` anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2022-12-10 21:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Sat, Dec 10, 2022 at 07:37:06PM +0000, anlauf at gcc dot gnu.org wrote:
> (In reply to kargl from comment #1)
> > This patch prevents the ICE.
> 
> The patch is mostly good, but does not set the errmsg variable, which
> leads to garbage in the printed error message.
> 
> We could do the following (haven't found a better one yet):
> 

Don't see the point in complicating the patch as there
is at least one earlier error message.  But, since I
won't be committing a chnage, I certainly won't object
to your patch.

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

* [Bug fortran/107995] ICE: Segmentation fault, without backtrace
  2022-12-06 18:06 [Bug fortran/107995] New: ICE: Segmentation fault, without backtrace gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-12-10 21:05 ` sgk at troutmask dot apl.washington.edu
@ 2022-12-10 21:24 ` anlauf at gcc dot gnu.org
  2022-12-11 19:35 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-10 21:24 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |kargl at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #4 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2022-December/058614.html

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

* [Bug fortran/107995] ICE: Segmentation fault, without backtrace
  2022-12-06 18:06 [Bug fortran/107995] New: ICE: Segmentation fault, without backtrace gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-12-10 21:24 ` anlauf at gcc dot gnu.org
@ 2022-12-11 19:35 ` cvs-commit at gcc dot gnu.org
  2022-12-12 20:23 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-11 19:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:8f72249ff4cbd0a5c701b99ee8aa1ca9d82df046

commit r13-4605-g8f72249ff4cbd0a5c701b99ee8aa1ca9d82df046
Author: Steve Kargl <kargl@gcc.gnu.org>
Date:   Sat Dec 10 22:17:15 2022 +0100

    Fortran: fix ICE on bad use of statement function [PR107995]

    gcc/fortran/ChangeLog:

            PR fortran/107995
            * interface.cc (gfc_check_dummy_characteristics): Reject statement
            function dummy arguments.

    gcc/testsuite/ChangeLog:

            PR fortran/107995
            * gfortran.dg/pr107995.f90: New test.

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

* [Bug fortran/107995] ICE: Segmentation fault, without backtrace
  2022-12-06 18:06 [Bug fortran/107995] New: ICE: Segmentation fault, without backtrace gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-12-11 19:35 ` cvs-commit at gcc dot gnu.org
@ 2022-12-12 20:23 ` anlauf at gcc dot gnu.org
  2022-12-12 21:43 ` sgk at troutmask dot apl.washington.edu
  2022-12-12 21:49 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-12 20:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from anlauf at gcc dot gnu.org ---
Can we close this one?  (Target milestone 13)?

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

* [Bug fortran/107995] ICE: Segmentation fault, without backtrace
  2022-12-06 18:06 [Bug fortran/107995] New: ICE: Segmentation fault, without backtrace gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2022-12-12 20:23 ` anlauf at gcc dot gnu.org
@ 2022-12-12 21:43 ` sgk at troutmask dot apl.washington.edu
  2022-12-12 21:49 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2022-12-12 21:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Mon, Dec 12, 2022 at 08:23:39PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107995
> 
> --- Comment #6 from anlauf at gcc dot gnu.org ---
> Can we close this one?  (Target milestone 13)?
> 

Yes, I think so.  The code surely is a corner case.

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

* [Bug fortran/107995] ICE: Segmentation fault, without backtrace
  2022-12-06 18:06 [Bug fortran/107995] New: ICE: Segmentation fault, without backtrace gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2022-12-12 21:43 ` sgk at troutmask dot apl.washington.edu
@ 2022-12-12 21:49 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-12 21:49 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |13.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from anlauf at gcc dot gnu.org ---
Fixed for gcc-13.  Closing.

Thanks for the report, and to Steve for the patch!

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

end of thread, other threads:[~2022-12-12 21:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06 18:06 [Bug fortran/107995] New: ICE: Segmentation fault, without backtrace gscfq@t-online.de
2022-12-10  2:19 ` [Bug fortran/107995] " kargl at gcc dot gnu.org
2022-12-10 19:37 ` anlauf at gcc dot gnu.org
2022-12-10 21:05 ` sgk at troutmask dot apl.washington.edu
2022-12-10 21:24 ` anlauf at gcc dot gnu.org
2022-12-11 19:35 ` cvs-commit at gcc dot gnu.org
2022-12-12 20:23 ` anlauf at gcc dot gnu.org
2022-12-12 21:43 ` sgk at troutmask dot apl.washington.edu
2022-12-12 21: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).