public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/35846]  New: ICE on nested character constructors
@ 2008-04-06 16:20 burnus at gcc dot gnu dot org
  2008-04-13 20:33 ` [Bug fortran/35846] " tkoenig at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-04-06 16:20 UTC (permalink / raw)
  To: gcc-bugs

The following program gives an ICE. One reason could be the global variables.
(cf. PR27997 comment 21).

implicit none
integer i
character(len=2) :: c(3)
c = 'a'
c = [ [ trim(c(1)), 'a' ]//'c', 'cd' ]
print *, c
end

Variants to check (or combinations of those):
- Compile with -fbounds-check
- Use  c = '' or  c = 'ab'
- Use typespec after PR27997 has been fixed, either on the inner or on the
outer loop. E.g.
  c = [ [ character(1):: trim(c(1)), 'a' ]//'c', 'cd' ]
etc.


-- 
           Summary: ICE on nested character constructors
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/35846] ICE on nested character constructors
  2008-04-06 16:20 [Bug fortran/35846] New: ICE on nested character constructors burnus at gcc dot gnu dot org
  2008-04-13 20:33 ` [Bug fortran/35846] " tkoenig at gcc dot gnu dot org
@ 2008-04-13 20:33 ` tkoenig at gcc dot gnu dot org
  2008-05-20  7:33 ` d at domob dot eu
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-04-13 20:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from tkoenig at gcc dot gnu dot org  2008-04-13 20:32 -------
Created an attachment (id=15474)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15474&action=view)
Backtrace

Confirmed.  Backtrace is attached.


-- 


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


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

* [Bug fortran/35846] ICE on nested character constructors
  2008-04-06 16:20 [Bug fortran/35846] New: ICE on nested character constructors burnus at gcc dot gnu dot org
@ 2008-04-13 20:33 ` tkoenig at gcc dot gnu dot org
  2008-04-13 20:33 ` tkoenig at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-04-13 20:33 UTC (permalink / raw)
  To: gcc-bugs



-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-04-13 20:33:00
               date|                            |


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


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

* [Bug fortran/35846] ICE on nested character constructors
  2008-04-06 16:20 [Bug fortran/35846] New: ICE on nested character constructors burnus at gcc dot gnu dot org
  2008-04-13 20:33 ` [Bug fortran/35846] " tkoenig at gcc dot gnu dot org
  2008-04-13 20:33 ` tkoenig at gcc dot gnu dot org
@ 2008-05-20  7:33 ` d at domob dot eu
  2008-05-21 15:06 ` d at domob dot eu
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: d at domob dot eu @ 2008-05-20  7:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from d at domob dot eu  2008-05-20 07:33 -------
Created an attachment (id=15655)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15655&action=view)
Hackish patch

It seems the problem lies in gfc_conv_string_length, that can be called with a
gfc_charlen whose length is NULL.   This patch is somewhat a prove of concept
of this, just creating a dummy length if it is NULL there; this prevents the
ICEs described above.

Of course this is surely not the correct place to do this initialization, I'll
try to find it out later and work out a real patch.


-- 


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


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

* [Bug fortran/35846] ICE on nested character constructors
  2008-04-06 16:20 [Bug fortran/35846] New: ICE on nested character constructors burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-05-21 15:06 ` d at domob dot eu
@ 2008-05-21 15:06 ` d at domob dot eu
  2008-09-18 18:24 ` domob at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: d at domob dot eu @ 2008-05-21 15:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from d at domob dot eu  2008-05-21 15:06 -------
Created an attachment (id=15664)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15664&action=view)
Testcase without nested array constructors

Actually, this does not depend on nested array constructors as this test-case
proves (and also has nothing to do with the globals used for bounds-checking,
it seems).

I believe the problem is that the gfc_expr* corresponding to the concatenation
doesn't have a cl->length set on its ts (because the arguments don't have one
when resolution is called); this NULL later causes the ICE.  When this
expression turns up in an assignment, this does not matter as the expected
length is known from the target's character length definition.

But when there is no "expected" charlen (like in the nested constructor or in a
function call as in this test) it is needed and the NULL pointer dereferenced. 
Hopefully I can soon come up with a real solution to this problem.


-- 


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


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

* [Bug fortran/35846] ICE on nested character constructors
  2008-04-06 16:20 [Bug fortran/35846] New: ICE on nested character constructors burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-05-20  7:33 ` d at domob dot eu
@ 2008-05-21 15:06 ` d at domob dot eu
  2008-05-21 15:06 ` d at domob dot eu
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: d at domob dot eu @ 2008-05-21 15:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from d at domob dot eu  2008-05-21 15:06 -------
Created an attachment (id=15663)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15663&action=view)
Testcase without nested array constructors

Actually, this does not depend on nested array constructors as this test-case
proves (and also has nothing to do with the globals used for bounds-checking,
it seems).

I believe the problem is that the gfc_expr* corresponding to the concatenation
doesn't have a cl->length set on its ts (because the arguments don't have one
when resolution is called); this NULL later causes the ICE.  When this
expression turns up in an assignment, this does not matter as the expected
length is known from the target's character length definition.

But when there is no "expected" charlen (like in the nested constructor or in a
function call as in this test) it is needed and the NULL pointer dereferenced. 
Hopefully I can soon come up with a real solution to this patch.


-- 


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


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

* [Bug fortran/35846] ICE on nested character constructors
  2008-04-06 16:20 [Bug fortran/35846] New: ICE on nested character constructors burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-05-21 15:06 ` d at domob dot eu
@ 2008-09-18 18:24 ` domob at gcc dot gnu dot org
  2008-09-20 11:54 ` domob at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-09-18 18:24 UTC (permalink / raw)
  To: gcc-bugs



-- 

domob at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |domob at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-04-13 20:33:00         |2008-09-18 18:22:59
               date|                            |


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


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

* [Bug fortran/35846] ICE on nested character constructors
  2008-04-06 16:20 [Bug fortran/35846] New: ICE on nested character constructors burnus at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-09-18 18:24 ` domob at gcc dot gnu dot org
@ 2008-09-20 11:54 ` domob at gcc dot gnu dot org
  2008-09-21 15:36 ` domob at gcc dot gnu dot org
  2008-09-21 15:37 ` domob at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-09-20 11:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from domob at gcc dot gnu dot org  2008-09-20 11:52 -------
After coming back to this bug, I believe the problem is that gfc_conv_expr
takes care of finding out string lengths' for things like TRIM(x) which don't
have a cl->length, but gfc_conv_expr_descriptor which is called e.g. for the
array constructors does not do so and calls gfc_conv_string_length with a cl
whose length is NULL.

As the problem seems to be specific to array constructors and all array
constructor elements must have the same character length, I propose to re-use
gfc_conv_expr in gfc_conv_string_length to find out the string length if it is
NULL by taking the first element of each array constructor and then calling
gfc_conv_expr to get the result's string_length.

I'll submit a patch shortly if no further problems occur.


-- 


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


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

* [Bug fortran/35846] ICE on nested character constructors
  2008-04-06 16:20 [Bug fortran/35846] New: ICE on nested character constructors burnus at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2008-09-20 11:54 ` domob at gcc dot gnu dot org
@ 2008-09-21 15:36 ` domob at gcc dot gnu dot org
  2008-09-21 15:37 ` domob at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-09-21 15:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from domob at gcc dot gnu dot org  2008-09-21 15:35 -------
Subject: Bug 35846

Author: domob
Date: Sun Sep 21 15:33:37 2008
New Revision: 140529

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140529
Log:
2008-09-21  Daniel Kraft  <d@domob.eu>

        PR fortran/35846
        * trans.h (gfc_conv_string_length): New argument `expr'.
        * trans-expr.c (flatten_array_ctors_without_strlen): New method.
        (gfc_conv_string_length): New argument `expr' that is used in a new
        special case handling if cl->length is NULL.
        (gfc_conv_subref_array_arg): Pass expr to gfc_conv_string_length.
        * trans-array.c (gfc_conv_expr_descriptor): Ditto.
        (gfc_trans_auto_array_allocation): Pass NULL as new expr.
        (gfc_trans_g77_array), (gfc_trans_dummy_array_bias): Ditto.
        (gfc_trans_deferred_array): Ditto.
        (gfc_trans_array_constructor): Save and restore old values of globals
        used for bounds checking.
        * trans-decl.c (gfc_trans_dummy_character): Ditto.
        (gfc_trans_auto_character_variable): Ditto.

2008-09-21  Daniel Kraft  <d@domob.eu>

        PR fortran/35846
        * gfortran.dg/nested_array_constructor_1.f90: New test.
        * gfortran.dg/nested_array_constructor_2.f90: New test.
        * gfortran.dg/nested_array_constructor_3.f90: New test.
        * gfortran.dg/nested_array_constructor_4.f90: New test.
        * gfortran.dg/nested_array_constructor_5.f90: New test.
        * gfortran.dg/nested_array_constructor_6.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/nested_array_constructor_1.f90
    trunk/gcc/testsuite/gfortran.dg/nested_array_constructor_2.f90
    trunk/gcc/testsuite/gfortran.dg/nested_array_constructor_3.f90
    trunk/gcc/testsuite/gfortran.dg/nested_array_constructor_4.f90
    trunk/gcc/testsuite/gfortran.dg/nested_array_constructor_5.f90
    trunk/gcc/testsuite/gfortran.dg/nested_array_constructor_6.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans.h
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/35846] ICE on nested character constructors
  2008-04-06 16:20 [Bug fortran/35846] New: ICE on nested character constructors burnus at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2008-09-21 15:36 ` domob at gcc dot gnu dot org
@ 2008-09-21 15:37 ` domob at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-09-21 15:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from domob at gcc dot gnu dot org  2008-09-21 15:36 -------
Fixed on trunk.


-- 

domob at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2008-09-21 15:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-06 16:20 [Bug fortran/35846] New: ICE on nested character constructors burnus at gcc dot gnu dot org
2008-04-13 20:33 ` [Bug fortran/35846] " tkoenig at gcc dot gnu dot org
2008-04-13 20:33 ` tkoenig at gcc dot gnu dot org
2008-05-20  7:33 ` d at domob dot eu
2008-05-21 15:06 ` d at domob dot eu
2008-05-21 15:06 ` d at domob dot eu
2008-09-18 18:24 ` domob at gcc dot gnu dot org
2008-09-20 11:54 ` domob at gcc dot gnu dot org
2008-09-21 15:36 ` domob at gcc dot gnu dot org
2008-09-21 15:37 ` domob at gcc dot gnu dot 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).