public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/50585] New: ICE with assumed length character array argument
@ 2011-10-01  7:36 sgm at objexx dot com
  2011-10-01  9:56 ` [Bug fortran/50585] [4.6/4.7 Regression] " janus at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: sgm at objexx dot com @ 2011-10-01  7:36 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50585
           Summary: ICE with assumed length character array argument
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sgm@objexx.com


Compiling these 2 routines in the same source file with gfortran -c

      SUBROUTINE SUB1( str )
      IMPLICIT NONE
      CHARACTER(len=*) :: str(2)
      CALL SUB2( str(1)(:3) )
      END SUBROUTINE SUB1

      SUBROUTINE SUB2( str )
      IMPLICIT NONE
      CHARACTER(*) :: str
      END SUBROUTINE SUB2

gives this ICE:

f951: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.

with gfortran 4.6.1 on Fedora 15 (x64) and with MinGW on Win32.

The problem was also observed on 4.6.0 on Fedora 15 but was not seen on 4.5.x.

The ICE does not occur if any of these are true:
 -fno-whole-file is used
 The routines are in separate files 
 The str array is changed to a scalar
 The str length is changed to a constant


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

* [Bug fortran/50585] [4.6/4.7 Regression] ICE with assumed length character array argument
  2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
@ 2011-10-01  9:56 ` janus at gcc dot gnu.org
  2011-10-01 10:04 ` janus at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-01  9:56 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janus at gcc dot gnu.org
      Known to work|                            |4.5.3
            Summary|ICE with assumed length     |[4.6/4.7 Regression] ICE
                   |character array argument    |with assumed length
                   |                            |character array argument
      Known to fail|                            |4.6.1, 4.7.0

--- Comment #1 from janus at gcc dot gnu.org 2011-10-01 09:55:59 UTC ---
This is a regression: Works with 4.5, but fails with 4.6 and trunk.


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

* [Bug fortran/50585] [4.6/4.7 Regression] ICE with assumed length character array argument
  2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
  2011-10-01  9:56 ` [Bug fortran/50585] [4.6/4.7 Regression] " janus at gcc dot gnu.org
@ 2011-10-01 10:04 ` janus at gcc dot gnu.org
  2011-10-01 10:10 ` janus at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-01 10:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from janus at gcc dot gnu.org 2011-10-01 10:03:33 UTC ---
Backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00000000004e1f73 in get_expr_storage_size (e=0x1bc4940) at
/home/jweil/gcc47/trunk/gcc/fortran/interface.c:1963
1963                      || ref->u.ss.length->length->expr_type !=
EXPR_CONSTANT)
(gdb) bt
#0  0x00000000004e1f73 in get_expr_storage_size (e=0x1bc4940) at
/home/jweil/gcc47/trunk/gcc/fortran/interface.c:1963
#1  0x00000000004e2dbf in compare_actual_formal (ap=0x1bc4fc0,
formal=0x1bc48a0, ranks_must_agree=0, is_elemental=0, where=0x1bc4f58)
    at /home/jweil/gcc47/trunk/gcc/fortran/interface.c:2248
#2  0x00000000004e46ff in gfc_procedure_use (sym=0x1bc5a10, ap=0x1bc4fc0,
where=0x1bc4f58) at /home/jweil/gcc47/trunk/gcc/fortran/interface.c:2877
#3  0x00000000005365a0 in resolve_global_procedure (sym=0x1bc45e0,
where=0x1bc4f58, actual=0x1bc4fc0, sub=<optimized out>)
    at /home/jweil/gcc47/trunk/gcc/fortran/resolve.c:2254
#4  0x000000000053e3f8 in resolve_call (c=0x1bc4f40) at
/home/jweil/gcc47/trunk/gcc/fortran/resolve.c:3656
#5  0x0000000000542a31 in resolve_code (code=0x1bc4f40, ns=<optimized out>) at
/home/jweil/gcc47/trunk/gcc/fortran/resolve.c:9310
#6  0x0000000000544c7d in resolve_codes (ns=0x1bc3210) at
/home/jweil/gcc47/trunk/gcc/fortran/resolve.c:13658
#7  0x000000000053617c in gfc_resolve (ns=0x1bc3210) at
/home/jweil/gcc47/trunk/gcc/fortran/resolve.c:13685
#8  0x0000000000529ebf in resolve_all_program_units
(gfc_global_ns_list=0x1bc3210) at
/home/jweil/gcc47/trunk/gcc/fortran/parse.c:4336
#9  0x000000000052a6b7 in gfc_parse_file () at
/home/jweil/gcc47/trunk/gcc/fortran/parse.c:4602
#10 0x0000000000567c1b in gfc_be_parse_file () at
/home/jweil/gcc47/trunk/gcc/fortran/f95-lang.c:250
#11 0x0000000000b5b2fc in compile_file () at
/home/jweil/gcc47/trunk/gcc/toplev.c:565
#12 0x0000000000b5d5b5 in do_compile () at
/home/jweil/gcc47/trunk/gcc/toplev.c:1925
#13 0x0000000000b5d72c in toplev_main (argc=2, argv=0x7fffffffddc8) at
/home/jweil/gcc47/trunk/gcc/toplev.c:2001
#14 0x000000000061e71c in main (argc=2, argv=0x7fffffffddc8) at
/home/jweil/gcc47/trunk/gcc/main.c:36


The problem is:

(gdb) p ref->u.ss.length->length
$3 = (struct gfc_expr *) 0x0


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

* [Bug fortran/50585] [4.6/4.7 Regression] ICE with assumed length character array argument
  2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
  2011-10-01  9:56 ` [Bug fortran/50585] [4.6/4.7 Regression] " janus at gcc dot gnu.org
  2011-10-01 10:04 ` janus at gcc dot gnu.org
@ 2011-10-01 10:10 ` janus at gcc dot gnu.org
  2011-10-01 10:15 ` dominiq at lps dot ens.fr
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-01 10:10 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011-10-01
     Ever Confirmed|0                           |1

--- Comment #3 from janus at gcc dot gnu.org 2011-10-01 10:09:56 UTC ---
Simple fix:

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c     (revision 179412)
+++ gcc/fortran/interface.c     (working copy)
@@ -1959,7 +1959,7 @@
            {
              /* The string length is the substring length.
                 Set now to full string length.  */
-             if (ref->u.ss.length == NULL
+             if (!ref->u.ss.length || !ref->u.ss.length->length
                  || ref->u.ss.length->length->expr_type != EXPR_CONSTANT)
                return 0;


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

* [Bug fortran/50585] [4.6/4.7 Regression] ICE with assumed length character array argument
  2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
                   ` (2 preceding siblings ...)
  2011-10-01 10:10 ` janus at gcc dot gnu.org
@ 2011-10-01 10:15 ` dominiq at lps dot ens.fr
  2011-10-01 10:25 ` janus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-10-01 10:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-10-01 10:15:31 UTC ---
> This is a regression: Works with 4.5, but fails with 4.6 and trunk.

4.5 gives a segmentation fault with  -fwhole-file (4.4 does not accept this
option).


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

* [Bug fortran/50585] [4.6/4.7 Regression] ICE with assumed length character array argument
  2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
                   ` (3 preceding siblings ...)
  2011-10-01 10:15 ` dominiq at lps dot ens.fr
@ 2011-10-01 10:25 ` janus at gcc dot gnu.org
  2011-10-01 11:25 ` janus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-01 10:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from janus at gcc dot gnu.org 2011-10-01 10:24:42 UTC ---
(In reply to comment #4)
> 4.5 gives a segmentation fault with  -fwhole-file (4.4 does not accept this
> option).

Well, then one can even argue that it's a regression in 4.5, too.

IIRC, -fwhole-file is default since 4.6, right? However, if this is true, it is
not documented in the manual:

http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gfortran/Code-Gen-Options.html#Code-Gen-Options


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

* [Bug fortran/50585] [4.6/4.7 Regression] ICE with assumed length character array argument
  2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
                   ` (4 preceding siblings ...)
  2011-10-01 10:25 ` janus at gcc dot gnu.org
@ 2011-10-01 11:25 ` janus at gcc dot gnu.org
  2011-10-01 11:42 ` janus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-01 11:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from janus at gcc dot gnu.org 2011-10-01 11:24:46 UTC ---
(In reply to comment #5)
> IIRC, -fwhole-file is default since 4.6, right? However, if this is true, it is
> not documented in the manual:
> 
> http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gfortran/Code-Gen-Options.html#Code-Gen-Options

Apparently I do remember correctly, as http://gcc.gnu.org/gcc-4.6/changes.html
confirms.


Also the patch in comment #3 regtests cleanly. Will commit as obvious.


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

* [Bug fortran/50585] [4.6/4.7 Regression] ICE with assumed length character array argument
  2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
                   ` (5 preceding siblings ...)
  2011-10-01 11:25 ` janus at gcc dot gnu.org
@ 2011-10-01 11:42 ` janus at gcc dot gnu.org
  2011-10-01 12:13 ` janus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-01 11:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from janus at gcc dot gnu.org 2011-10-01 11:41:49 UTC ---
Author: janus
Date: Sat Oct  1 11:41:41 2011
New Revision: 179413

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179413
Log:
2011-10-01  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/50585
    * interface.c (get_expr_storage_size): Check if 'length' component is
    associated.


2011-10-01  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/50585
    * gfortran.dg/assumed_charlen_arg_2.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/assumed_charlen_arg_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/50585] [4.6/4.7 Regression] ICE with assumed length character array argument
  2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
                   ` (6 preceding siblings ...)
  2011-10-01 11:42 ` janus at gcc dot gnu.org
@ 2011-10-01 12:13 ` janus at gcc dot gnu.org
  2011-10-07 21:01 ` janus at gcc dot gnu.org
  2011-10-07 21:24 ` janus at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-01 12:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from janus at gcc dot gnu.org 2011-10-01 12:13:04 UTC ---
Fixed on trunk with r179413. Backport to 4.6 (and 4.5?) pending ...


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

* [Bug fortran/50585] [4.6/4.7 Regression] ICE with assumed length character array argument
  2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
                   ` (7 preceding siblings ...)
  2011-10-01 12:13 ` janus at gcc dot gnu.org
@ 2011-10-07 21:01 ` janus at gcc dot gnu.org
  2011-10-07 21:24 ` janus at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-07 21:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from janus at gcc dot gnu.org 2011-10-07 21:01:06 UTC ---
Author: janus
Date: Fri Oct  7 21:01:02 2011
New Revision: 179696

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179696
Log:
2011-10-07  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/50585
    * interface.c (get_expr_storage_size): Check if 'length' component is
    associated.

    PR fortran/50625
    * class.c (gfc_build_class_symbol): Fix whitespace.
    * module.c (mio_symbol): Set 'class_ok' attribute.
    * trans-decl.c (gfc_get_symbol_decl): Make sure the backend_decl has
    been built for class symbols.


2011-10-07  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/50585
    * gfortran.dg/assumed_charlen_arg_2.f90: New.

    PR fortran/50625
    * gfortran.dg/class_46.f03: New.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/assumed_charlen_arg_2.f90
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/class_46.f03
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/class.c
    branches/gcc-4_6-branch/gcc/fortran/interface.c
    branches/gcc-4_6-branch/gcc/fortran/module.c
    branches/gcc-4_6-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/50585] [4.6/4.7 Regression] ICE with assumed length character array argument
  2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
                   ` (8 preceding siblings ...)
  2011-10-07 21:01 ` janus at gcc dot gnu.org
@ 2011-10-07 21:24 ` janus at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2011-10-07 21:24 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

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

--- Comment #10 from janus at gcc dot gnu.org 2011-10-07 21:23:47 UTC ---
Fixed on 4.6 and trunk. Closing.

Thanks for the report!


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

end of thread, other threads:[~2011-10-07 21:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-01  7:36 [Bug fortran/50585] New: ICE with assumed length character array argument sgm at objexx dot com
2011-10-01  9:56 ` [Bug fortran/50585] [4.6/4.7 Regression] " janus at gcc dot gnu.org
2011-10-01 10:04 ` janus at gcc dot gnu.org
2011-10-01 10:10 ` janus at gcc dot gnu.org
2011-10-01 10:15 ` dominiq at lps dot ens.fr
2011-10-01 10:25 ` janus at gcc dot gnu.org
2011-10-01 11:25 ` janus at gcc dot gnu.org
2011-10-01 11:42 ` janus at gcc dot gnu.org
2011-10-01 12:13 ` janus at gcc dot gnu.org
2011-10-07 21:01 ` janus at gcc dot gnu.org
2011-10-07 21:24 ` janus 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).