[Bug fortran/107995] ICE: Segmentation fault, without backtrace

2022-12-12 Thread anlauf at gcc dot gnu.org via 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!

[Bug fortran/107995] ICE: Segmentation fault, without backtrace

2022-12-12 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107995

--- Comment #7 from Steve Kargl  ---
On Mon, Dec 12, 2022 at 08:23:39PM +, 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.

[Bug fortran/107995] ICE: Segmentation fault, without backtrace

2022-12-12 Thread anlauf at gcc dot gnu.org via 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)?

[Bug fortran/107995] ICE: Segmentation fault, without backtrace

2022-12-11 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107995

--- Comment #5 from CVS Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:8f72249ff4cbd0a5c701b99ee8aa1ca9d82df046

commit r13-4605-g8f72249ff4cbd0a5c701b99ee8aa1ca9d82df046
Author: Steve Kargl 
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.

[Bug fortran/107995] ICE: Segmentation fault, without backtrace

2022-12-10 Thread anlauf at gcc dot gnu.org via 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

[Bug fortran/107995] ICE: Segmentation fault, without backtrace

2022-12-10 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107995

--- Comment #3 from Steve Kargl  ---
On Sat, Dec 10, 2022 at 07:37:06PM +, 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.

[Bug fortran/107995] ICE: Segmentation fault, without backtrace

2022-12-10 Thread anlauf at gcc dot gnu.org via 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

[Bug fortran/107995] ICE: Segmentation fault, without backtrace

2022-12-09 Thread kargl at gcc dot gnu.org via 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)
 {