public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/50163] New: Internal compiler error: initialization expression
@ 2011-08-23  9:41 pmason at ricardo dot com
  2011-08-23 10:21 ` [Bug fortran/50163] " dominiq at lps dot ens.fr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pmason at ricardo dot com @ 2011-08-23  9:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50163

             Bug #: 50163
           Summary: Internal compiler error: initialization expression
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pmason@ricardo.com


Get following error message when compiling (gfortran -c test.f90):

f951: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Offending source code (test.f90):

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
module stringy
character(len=2) :: xx='aa'
integer :: iloc=index(xx,'bb')
end module stringy
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

NOTE: I think the code is slightly illegal - i.e. xx should be compile-time
constant. Compiles OK if xx is qualified as a parameter.


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

* [Bug fortran/50163] Internal compiler error: initialization expression
  2011-08-23  9:41 [Bug fortran/50163] New: Internal compiler error: initialization expression pmason at ricardo dot com
@ 2011-08-23 10:21 ` dominiq at lps dot ens.fr
  2011-08-23 12:14 ` [Bug fortran/50163] [4.3/4.4/4.5/4.6/4.7 Regression] ICE: " burnus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-08-23 10:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50163

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-08-23
     Ever Confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-08-23 10:07:42 UTC ---
Confirmed on 4.4.6, 4.5.3, 4.6.1, and trunk. g95 and ifort reject the code with

[macbook] f90/bug% g95 pr50163.f90
In file pr50163.f90:3

integer :: iloc=index(xx,'bb')
                      1
Error: Variable 'xx' at (1) cannot appear in an initialization expression
[macbook] f90/bug% ifc pr50163.f90
pr50163.f90(3): error #6592: This symbol must be a defined parameter, an
enumerator, or an argument of an inquiry function that evaluates to a
compile-time constant.   [XX]
integer :: iloc=index(xx,'bb')
----------------------^
pr50163.f90(3): error #6973: This is not a valid initialization expression.  
[INDEX]
integer :: iloc=index(xx,'bb')
----------------^
compilation aborted for pr50163.f90 (code 1)

The segmentation fault is due to

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
check_init_expr (e=0x141f1c640) at ../../work/gcc/fortran/expr.c:1969
1969          if (a->expr->expr_type != EXPR_ARRAY)
(gdb) bt
#0  check_init_expr (e=0x141f1c640) at ../../work/gcc/fortran/expr.c:1969
#1  0x000000010002e778 in gfc_reduce_init_expr (expr=0x3) at
../../work/gcc/fortran/expr.c:2626
Current language:  auto; currently c++
(gdb) p *a
$3 = {
  name = 0x0, 
  label = 0x0, 
  missing_arg_type = BT_LOGICAL, 
  expr = 0x0, 
  next = 0x141f1cac0
}


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

* [Bug fortran/50163] [4.3/4.4/4.5/4.6/4.7 Regression] ICE: initialization expression
  2011-08-23  9:41 [Bug fortran/50163] New: Internal compiler error: initialization expression pmason at ricardo dot com
  2011-08-23 10:21 ` [Bug fortran/50163] " dominiq at lps dot ens.fr
@ 2011-08-23 12:14 ` burnus at gcc dot gnu.org
  2011-08-24 13:26 ` burnus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-08-23 12:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50163

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
                 CC|                            |burnus at gcc dot gnu.org
      Known to work|                            |4.1.2
   Target Milestone|---                         |4.6.2
            Summary|Internal compiler error:    |[4.3/4.4/4.5/4.6/4.7
                   |initialization expression   |Regression] ICE:
                   |                            |initialization expression
      Known to fail|                            |4.3.4, 4.5.3, 4.6.1, 4.7.0

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-08-23 10:37:38 UTC ---
That's actually a regression: With 4.1.2 I get:

  integer :: iloc=index(xx,'bb')
                       1
  Error: Parameter 'xx' at (1) has not been declared or is a variable,
  which does not reduce to a constant expression

While with GCC 4.3.4 and later, I get an ICE. I have not tested 4.2.

 * * *

The problem seems to be the delayed error output. In expr.c's check_init_expr,
one has:

        if ((m = check_conversion (e)) == MATCH_NO
            && (m = check_inquiry (e, 1)) == MATCH_NO
            && (m = check_null (e)) == MATCH_NO
            && (m = check_transformational (e)) == MATCH_NO
            && (m = check_elemental (e)) == MATCH_NO)
          {
            gfc_error ("Intrinsic function '%s' at %L is not permitted "
                       "in an initialization expression",
                       e->symtree->n.sym->name, &e->where);
            m = MATCH_ERROR;
          }

        /* Try to scalarize an elemental intrinsic function that has an
           array argument.  */
        isym = gfc_find_function (e->symtree->n.sym->name);
        if (isym && isym->elemental
            && (t = scalarize_intrinsic_call (e)) == SUCCESS)


What happens now is: "check_elemental" prints an error (which gets buffered)
and returns MATCH_ERROR. However, that value is not checked - thus the code
continues to the scalarize_intrinsic_call(e), which then gives an ICE.


Draft patch (only very lightly tested):

--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2481,6 +2481,9 @@ check_init_expr (gfc_expr *e)
            m = MATCH_ERROR;
          }

+       if (m == MATCH_ERROR)
+         return FAILURE;
+
        /* Try to scalarize an elemental intrinsic function that has an
           array argument.  */
        isym = gfc_find_function (e->symtree->n.sym->name);


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

* [Bug fortran/50163] [4.3/4.4/4.5/4.6/4.7 Regression] ICE: initialization expression
  2011-08-23  9:41 [Bug fortran/50163] New: Internal compiler error: initialization expression pmason at ricardo dot com
  2011-08-23 10:21 ` [Bug fortran/50163] " dominiq at lps dot ens.fr
  2011-08-23 12:14 ` [Bug fortran/50163] [4.3/4.4/4.5/4.6/4.7 Regression] ICE: " burnus at gcc dot gnu.org
@ 2011-08-24 13:26 ` burnus at gcc dot gnu.org
  2011-08-24 14:02 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-08-24 13:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50163

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-08-24 13:11:14 UTC ---
Author: burnus
Date: Wed Aug 24 13:11:08 2011
New Revision: 178038

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178038
Log:
2011-08-24  Tobias Burnus  <burnus@net-b.de>

        PR fortran/50163
        * expr.c (check_init_expr): Return when an error
        occured.

2011-08-24  Tobias Burnus  <burnus@net-b.de>

        PR fortran/50163
        * gfortran.dg/initialization_28.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/initialization_28.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/50163] [4.3/4.4/4.5/4.6/4.7 Regression] ICE: initialization expression
  2011-08-23  9:41 [Bug fortran/50163] New: Internal compiler error: initialization expression pmason at ricardo dot com
                   ` (2 preceding siblings ...)
  2011-08-24 13:26 ` burnus at gcc dot gnu.org
@ 2011-08-24 14:02 ` jakub at gcc dot gnu.org
  2011-08-25  8:33 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-08-24 14:02 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50163

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |jakub at gcc dot gnu.org


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

* [Bug fortran/50163] [4.3/4.4/4.5/4.6/4.7 Regression] ICE: initialization expression
  2011-08-23  9:41 [Bug fortran/50163] New: Internal compiler error: initialization expression pmason at ricardo dot com
                   ` (3 preceding siblings ...)
  2011-08-24 14:02 ` jakub at gcc dot gnu.org
@ 2011-08-25  8:33 ` burnus at gcc dot gnu.org
  2011-08-30  7:26 ` [Bug fortran/50163] [4.4/4.5 " burnus at gcc dot gnu.org
  2011-08-30 12:24 ` [Bug fortran/50163] [4.4/4.5/4.6/4.7 " burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-08-25  8:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50163

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-08-25 08:29:36 UTC ---
Author: burnus
Date: Thu Aug 25 08:29:29 2011
New Revision: 178054

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178054
Log:
2011-08-25  Tobias Burnus  <burnus@net-b.de>

        PR fortran/50163
        * check_init_expr (check_init_expr): Return when an error
        occured.

2011-08-25  Tobias Burnus  <burnus@net-b.de>

        PR fortran/50163
        * gfortran.dg/initialization_28.f90: New.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/initialization_28.f90
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/expr.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/50163] [4.4/4.5 Regression] ICE: initialization expression
  2011-08-23  9:41 [Bug fortran/50163] New: Internal compiler error: initialization expression pmason at ricardo dot com
                   ` (4 preceding siblings ...)
  2011-08-25  8:33 ` burnus at gcc dot gnu.org
@ 2011-08-30  7:26 ` burnus at gcc dot gnu.org
  2011-08-30 12:24 ` [Bug fortran/50163] [4.4/4.5/4.6/4.7 " burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-08-30  7:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50163

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-08-30 06:50:28 UTC ---
Author: burnus
Date: Tue Aug 30 06:50:22 2011
New Revision: 178280

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178280
Log:
2011-08-30  Tobias Burnus  <burnus@net-b.de>

        PR fortran/50163
        * check_init_expr (check_init_expr): Return when an error
        * occured.

2011-08-30  Tobias Burnus  <burnus@net-b.de>

        PR fortran/50163
        * gfortran.dg/initialization_28.f90: New.


Added:
    branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/initialization_28.f90
Modified:
    branches/gcc-4_5-branch/gcc/fortran/ChangeLog
    branches/gcc-4_5-branch/gcc/fortran/expr.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/50163] [4.4/4.5/4.6/4.7 Regression] ICE: initialization expression
  2011-08-23  9:41 [Bug fortran/50163] New: Internal compiler error: initialization expression pmason at ricardo dot com
                   ` (5 preceding siblings ...)
  2011-08-30  7:26 ` [Bug fortran/50163] [4.4/4.5 " burnus at gcc dot gnu.org
@ 2011-08-30 12:24 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-08-30 12:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50163

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.6.2                       |4.5.4
            Summary|[4.4/4.5 Regression] ICE:   |[4.4/4.5/4.6/4.7
                   |initialization expression   |Regression] ICE:
                   |                            |initialization expression

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-08-30 12:09:19 UTC ---
FIXED on the trunk (4.7) and on the 4.5 and 4.6 branches. As mere
ice-on-invalid-code bug, I decided not to backport it to 4.4. Anyone who wants
to have it also in 4.4: Feel free to either backport it yourself or to tell us.

Thanks for the bug report!


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

end of thread, other threads:[~2011-08-30 12:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-23  9:41 [Bug fortran/50163] New: Internal compiler error: initialization expression pmason at ricardo dot com
2011-08-23 10:21 ` [Bug fortran/50163] " dominiq at lps dot ens.fr
2011-08-23 12:14 ` [Bug fortran/50163] [4.3/4.4/4.5/4.6/4.7 Regression] ICE: " burnus at gcc dot gnu.org
2011-08-24 13:26 ` burnus at gcc dot gnu.org
2011-08-24 14:02 ` jakub at gcc dot gnu.org
2011-08-25  8:33 ` burnus at gcc dot gnu.org
2011-08-30  7:26 ` [Bug fortran/50163] [4.4/4.5 " burnus at gcc dot gnu.org
2011-08-30 12:24 ` [Bug fortran/50163] [4.4/4.5/4.6/4.7 " burnus 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).