public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203
@ 2021-08-03 18:35 gscfq@t-online.de
  2021-08-03 18:35 ` [Bug fortran/101762] " gscfq@t-online.de
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gscfq@t-online.de @ 2021-08-03 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101762
           Summary: ICE in ix86_push_argument, at config/i386/i386.c:4203
           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 :
(invocation of n() is not allowed at this position)


$ cat z1.f90
program p
   integer, target :: a(3) = [7, 8, 9]
   integer, pointer :: x => a(n())
   print *, x
end


$ gfortran-12-20210801 -c z1.f90
z1.f90:5:3:

    5 | end
      |   ^
internal compiler error: Segmentation fault
0xde5d0f crash_signal
        ../../gcc/toplev.c:328
0x11d09dd ix86_push_argument
        ../../gcc/config/i386/i386.c:4203
0x896e13 expand_call(tree_node*, rtx_def*, int)
        ../../gcc/calls.c:3731
0x9fa3f6 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:11511
0x9f431d expand_expr
        ../../gcc/expr.h:301
0x9f431d expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
        ../../gcc/expr.c:9044
0x9faae1 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:11796
0xa063be expand_expr
        ../../gcc/expr.h:301
0xa063be expand_operands(tree_node*, tree_node*, rtx_def*, rtx_def**,
rtx_def**, expand_modifier)
        ../../gcc/expr.c:8289
0x9f413c expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
        ../../gcc/expr.c:9255
0x9faae1 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:11796
0x9f697e expand_expr
        ../../gcc/expr.h:301
0x9f697e expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
        ../../gcc/expr.c:9031
0x9faae1 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:11796
0xa063be expand_expr
        ../../gcc/expr.h:301
0xa063be expand_operands(tree_node*, tree_node*, rtx_def*, rtx_def**,
rtx_def**, expand_modifier)
        ../../gcc/expr.c:8289
0x9f4efc expand_expr_real_2(separate_ops*, rtx_def*, machine_mode,
expand_modifier)
        ../../gcc/expr.c:9516
0x9faae1 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:11796
0xa06c77 expand_expr
        ../../gcc/expr.h:301
0xa06c77 expand_expr_addr_expr_1
        ../../gcc/expr.c:8456

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

* [Bug fortran/101762] ICE in ix86_push_argument, at config/i386/i386.c:4203
  2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
@ 2021-08-03 18:35 ` gscfq@t-online.de
  2022-01-02  5:40 ` [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression" pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: gscfq@t-online.de @ 2021-08-03 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

G. Steinmetz <gscfq@t-online.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
             Target|                            |x86_64-pc-linux-gnu

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

This expanded variant results in an error (an indirect hint) :

$ cat zz2.f90
program p
   integer, target :: a(3) = [7, 8, 9]
   integer, pointer :: x => a(n())
   print *, x
contains
   pure integer function n()
      n = 2
   end
end

$ gfortran-12-20210801 -c zz2.f90
zz2.f90:6:3:

    6 |    pure integer function n()
      |   1
Error: INTERNAL-PROC procedure at (1) is already declared as EXTERNAL-PROC
procedure



And for completeness, a correct version could look like this :

$ cat zz3.f90
program p
   integer, target :: a(3) = [7, 8, 9]
   integer, pointer :: x
   x => a(n())
   print *, x
contains
   pure integer function n()
      n = 2
   end
end

$ gfortran-12-20210801 zz3.f90 && ./a.out
           8
$

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

* [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression"
  2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
  2021-08-03 18:35 ` [Bug fortran/101762] " gscfq@t-online.de
@ 2022-01-02  5:40 ` pinskia at gcc dot gnu.org
  2022-01-02 20:42 ` anlauf at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-02  5:40 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE in ix86_push_argument,  |ICE with "Every subscript
                   |at config/i386/i386.c:4203  |of the target specification
                   |                            |must be a constant
                   |                            |expression"
   Last reconfirmed|                            |2022-01-02
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note ifort rejects it with:
/app/example.f90(4): error #8817: Every subscript of the target specification
must be a constant expression.   [A]
   integer, pointer :: x => a(n())
----------------------------^
compilation aborted for /app/example.f90 (code 1)
ASM generation compiler returned: 1

Confirmed.

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

* [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression"
  2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
  2021-08-03 18:35 ` [Bug fortran/101762] " gscfq@t-online.de
  2022-01-02  5:40 ` [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression" pinskia at gcc dot gnu.org
@ 2022-01-02 20:42 ` anlauf at gcc dot gnu.org
  2022-01-02 22:28 ` anlauf at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-02 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

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 ---
Untested patch:

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 4971638f9b6..9d37a71abb9 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -2525,6 +2525,9 @@ match_pointer_init (gfc_expr **init, int procptr)
                       "initialization at %C"))
     return MATCH_ERROR;

+  if (!gfc_check_init_expr (*init))
+    return MATCH_ERROR;
+
   return MATCH_YES;
 }

This would result in:

pr101762.f90:3:28:

    3 |   integer, pointer :: x => a(n())
      |                            1
Error: Array 'a' at (1) is a variable, which does not reduce to a constant
expression

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

* [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression"
  2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-01-02 20:42 ` anlauf at gcc dot gnu.org
@ 2022-01-02 22:28 ` anlauf at gcc dot gnu.org
  2022-01-03 19:46 ` anlauf at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-02 22:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from anlauf at gcc dot gnu.org ---
Created attachment 52108
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52108&action=edit
Improved patch

The previous patch was too strict.  The attached version does a much better
job, but needs more testing and provides more concise error messages also
for substrings.

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

* [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression"
  2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-01-02 22:28 ` anlauf at gcc dot gnu.org
@ 2022-01-03 19:46 ` anlauf at gcc dot gnu.org
  2022-01-09 21:08 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-03 19:46 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #5 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2022-January/057266.html

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

* [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression"
  2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-01-03 19:46 ` anlauf at gcc dot gnu.org
@ 2022-01-09 21:08 ` cvs-commit at gcc dot gnu.org
  2022-01-15 21:07 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-09 21:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 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:2e63128306ff93d8f53119137dd6c28b2defac94

commit r12-6387-g2e63128306ff93d8f53119137dd6c28b2defac94
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Jan 9 22:08:14 2022 +0100

    Fortran: reject invalid non-constant pointer initialization targets

    gcc/fortran/ChangeLog:

            PR fortran/101762
            * expr.c (gfc_check_pointer_assign): For pointer initialization
            targets, check that subscripts and substring indices in
            specifications are constant expressions.

    gcc/testsuite/ChangeLog:

            PR fortran/101762
            * gfortran.dg/pr101762.f90: New test.

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

* [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression"
  2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2022-01-09 21:08 ` cvs-commit at gcc dot gnu.org
@ 2022-01-15 21:07 ` cvs-commit at gcc dot gnu.org
  2022-01-15 21:11 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-15 21:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:27424f10d4ad28fbcceb1c9fc767605b4d46494c

commit r11-9463-g27424f10d4ad28fbcceb1c9fc767605b4d46494c
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Jan 9 22:08:14 2022 +0100

    Fortran: reject invalid non-constant pointer initialization targets

    gcc/fortran/ChangeLog:

            PR fortran/101762
            * expr.c (gfc_check_pointer_assign): For pointer initialization
            targets, check that subscripts and substring indices in
            specifications are constant expressions.

    gcc/testsuite/ChangeLog:

            PR fortran/101762
            * gfortran.dg/pr101762.f90: New test.

    (cherry picked from commit 2e63128306ff93d8f53119137dd6c28b2defac94)

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

* [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression"
  2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2022-01-15 21:07 ` cvs-commit at gcc dot gnu.org
@ 2022-01-15 21:11 ` anlauf at gcc dot gnu.org
  2022-01-25 19:37 ` cvs-commit at gcc dot gnu.org
  2022-01-25 20:03 ` anlauf at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-15 21:11 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |weeks at iastate dot edu

--- Comment #8 from anlauf at gcc dot gnu.org ---
*** Bug 85150 has been marked as a duplicate of this bug. ***

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

* [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression"
  2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2022-01-15 21:11 ` anlauf at gcc dot gnu.org
@ 2022-01-25 19:37 ` cvs-commit at gcc dot gnu.org
  2022-01-25 20:03 ` anlauf at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-25 19:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:a5f7e0838e1573f4cc33a6f2c70c60187d7a63af

commit r10-10419-ga5f7e0838e1573f4cc33a6f2c70c60187d7a63af
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Jan 9 22:08:14 2022 +0100

    Fortran: reject invalid non-constant pointer initialization targets

    gcc/fortran/ChangeLog:

            PR fortran/101762
            * expr.c (gfc_check_pointer_assign): For pointer initialization
            targets, check that subscripts and substring indices in
            specifications are constant expressions.

    gcc/testsuite/ChangeLog:

            PR fortran/101762
            * gfortran.dg/pr101762.f90: New test.

    (cherry picked from commit 2e63128306ff93d8f53119137dd6c28b2defac94)

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

* [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression"
  2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
                   ` (8 preceding siblings ...)
  2022-01-25 19:37 ` cvs-commit at gcc dot gnu.org
@ 2022-01-25 20:03 ` anlauf at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-01-25 20:03 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #10 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-12, and on 11- and 10-branch.

Backporting further is probably not necessary.  Closing.

Thanks for the report!

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

end of thread, other threads:[~2022-01-25 20:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 18:35 [Bug fortran/101762] New: ICE in ix86_push_argument, at config/i386/i386.c:4203 gscfq@t-online.de
2021-08-03 18:35 ` [Bug fortran/101762] " gscfq@t-online.de
2022-01-02  5:40 ` [Bug fortran/101762] ICE with "Every subscript of the target specification must be a constant expression" pinskia at gcc dot gnu.org
2022-01-02 20:42 ` anlauf at gcc dot gnu.org
2022-01-02 22:28 ` anlauf at gcc dot gnu.org
2022-01-03 19:46 ` anlauf at gcc dot gnu.org
2022-01-09 21:08 ` cvs-commit at gcc dot gnu.org
2022-01-15 21:07 ` cvs-commit at gcc dot gnu.org
2022-01-15 21:11 ` anlauf at gcc dot gnu.org
2022-01-25 19:37 ` cvs-commit at gcc dot gnu.org
2022-01-25 20:03 ` 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).