public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/45244]  New: Incorrect passing of character string array argument triggers an internal compiler error
@ 2010-08-10  2:07 Eric dot Zurcher at csiro dot au
  2010-08-10  2:17 ` [Bug fortran/45244] " Eric dot Zurcher at csiro dot au
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Eric dot Zurcher at csiro dot au @ 2010-08-10  2:07 UTC (permalink / raw)
  To: gcc-bugs




-- 
           Summary: Incorrect passing of character string array argument
                    triggers an internal compiler error
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Eric dot Zurcher at csiro dot au


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


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

* [Bug fortran/45244] Incorrect passing of character string array argument triggers an internal compiler error
  2010-08-10  2:07 [Bug fortran/45244] New: Incorrect passing of character string array argument triggers an internal compiler error Eric dot Zurcher at csiro dot au
@ 2010-08-10  2:17 ` Eric dot Zurcher at csiro dot au
  2010-08-10  2:37 ` kargl at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Eric dot Zurcher at csiro dot au @ 2010-08-10  2:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from Eric dot Zurcher at csiro dot au  2010-08-10 02:16 -------
The FORTRAN code given below causes gfortran to fail with the message:
f951.exe: internal compiler error: Segmentation fault

I have tested this using the Mingw32 version of gfortran 4.5.0, and version
4.3.2 on SUSE Linux. 

The code does contain a known error: the argument "variable" should be passed
as an array of strings, not as just the first string in the array. However,
this incorrect code should not cause the compiler to segmentation fault.



      Module BugDemo

      integer M
      parameter (M=100)

      Type aRecord
      SEQUENCE
        character        soil_type(0:M)*20 
      End Type aRecord

      Type (aRecord),Pointer ::  p

      contains

! ====================================================================
       subroutine read_char_array
     .     (section_name, variable_name, size_of,
     .      units, variable, numvals)
! ====================================================================
      implicit none

!+ Sub-Program Arguments
      character section_name*(*)       ! (INPUT) section name to search for
      character variable_name*(*)      ! (INPUT) Variable name to search for
      integer size_of                  ! (INPUT) size_of of array
      character units*(*)              ! (INPUT) Units required by caller
      character variable(*)*(*)        ! (OUTPUT) Variable returned to caller
      integer numvals                 ! (OUTPUT) Number of values returned

      logical found

!- Implementation Section ----------------------------------

      found = .TRUE.
      return
      end subroutine

      subroutine dotest

      !Use ReadModule
      Implicit None
      integer numvals

      allocate(p)       

              call Read_char_array (
     :              'init',
     :              'soil_type',
     :              M+1,
     :              '(?)',
     :              p%soil_type(0),   ! THIS IS WRONG
     :              numvals)

      deallocate(p)     
      return

      end subroutine

      end module BugDemo


-- 


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


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

* [Bug fortran/45244] Incorrect passing of character string array argument triggers an internal compiler error
  2010-08-10  2:07 [Bug fortran/45244] New: Incorrect passing of character string array argument triggers an internal compiler error Eric dot Zurcher at csiro dot au
  2010-08-10  2:17 ` [Bug fortran/45244] " Eric dot Zurcher at csiro dot au
@ 2010-08-10  2:37 ` kargl at gcc dot gnu dot org
  2010-08-10 17:50 ` kargl at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-08-10  2:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from kargl at gcc dot gnu dot org  2010-08-10 02:37 -------
Created an attachment (id=21444)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21444&action=view)
Reduced testcase

Reduced testcase.  gdb shows 

Program received signal SIGSEGV, Segmentation fault.
0x080ed4c0 in compare_actual_formal (ap=0x4969174c, formal=0x495054e8, 
    ranks_must_agree=0, is_elemental=0, where=0x4969171c)
    at ../../gcc4x/gcc/fortran/interface.c:1606
warning: Source file is more recent than executable.
1606        if (ref->type == REF_ARRAY && ref->u.ar.type == AR_ELEMENT
(gdb) bt
#0  0x080ed4c0 in compare_actual_formal (ap=0x4969174c, formal=0x495054e8, 
    ranks_must_agree=0, is_elemental=0, where=0x4969171c)
    at ../../gcc4x/gcc/fortran/interface.c:1606
#1  0x080eec1c in gfc_procedure_use (sym=0x496973c0, ap=0x4969174c, 
    where=0x4969171c) at ../../gcc4x/gcc/fortran/interface.c:2623
#2  0x0812a978 in resolve_call (c=0x49691710)
    at ../../gcc4x/gcc/fortran/resolve.c:3288
#3  0x0812b341 in resolve_code (code=0x49691710, ns=0x49623200)
    at ../../gcc4x/gcc/fortran/resolve.c:8617
#4  0x0812c453 in resolve_codes (ns=0x49623200)
    at ../../gcc4x/gcc/fortran/resolve.c:13052
#5  0x0812c37c in resolve_codes (ns=0x49621d00)
    at ../../gcc4x/gcc/fortran/resolve.c:13038
#6  0x0812c52c in gfc_resolve (ns=0x49621d00)
    at ../../gcc4x/gcc/fortran/resolve.c:13079
#7  0x0811f4c7 in gfc_parse_file () at ../../gcc4x/gcc/fortran/parse.c:4379
#8  0x08153e30 in gfc_be_parse_file (set_yydebug=0)
    at ../../gcc4x/gcc/fortran/f95-lang.c:236
#9  0x0848fc35 in do_compile () at ../../gcc4x/gcc/toplev.c:978
#10 0x084909c6 in toplev_main (argc=2, argv=0xbfbfe57c)
    at ../../gcc4x/gcc/toplev.c:2374
#11 0x081ada92 in main (argc=4, argv=0x6) at ../../gcc4x/gcc/main.c:36


-- 


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


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

* [Bug fortran/45244] Incorrect passing of character string array argument triggers an internal compiler error
  2010-08-10  2:07 [Bug fortran/45244] New: Incorrect passing of character string array argument triggers an internal compiler error Eric dot Zurcher at csiro dot au
  2010-08-10  2:17 ` [Bug fortran/45244] " Eric dot Zurcher at csiro dot au
  2010-08-10  2:37 ` kargl at gcc dot gnu dot org
@ 2010-08-10 17:50 ` kargl at gcc dot gnu dot org
  2010-08-10 20:19 ` kargl at gcc dot gnu dot org
  2010-08-10 20:43 ` mikael at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-08-10 17:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from kargl at gcc dot gnu dot org  2010-08-10 17:49 -------
Might as well confirm the bug.

This patch stops the segmentation fault, but I do not know
if it is the correct fix.

Index: interface.c
===================================================================
--- interface.c (revision 163075)
+++ interface.c (working copy)
@@ -1611,7 +1611,8 @@ compare_parameter (gfc_symbol *formal, g
   if (formal->ts.type == BT_CHARACTER
       && (ref == NULL
           || (actual->expr_type == EXPR_VARIABLE
-             && (actual->symtree->n.sym->as->type == AS_ASSUMED_SHAPE
+             && ((actual->symtree->n.sym->as
+                  && actual->symtree->n.sym->as->type == AS_ASSUMED_SHAPE)
                  || actual->symtree->n.sym->attr.pointer))))
     {
       if (where && (gfc_option.allow_std & GFC_STD_F2003) == 0)


-- 

kargl 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         |2010-08-10 17:49:56
               date|                            |


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


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

* [Bug fortran/45244] Incorrect passing of character string array argument triggers an internal compiler error
  2010-08-10  2:07 [Bug fortran/45244] New: Incorrect passing of character string array argument triggers an internal compiler error Eric dot Zurcher at csiro dot au
                   ` (2 preceding siblings ...)
  2010-08-10 17:50 ` kargl at gcc dot gnu dot org
@ 2010-08-10 20:19 ` kargl at gcc dot gnu dot org
  2010-08-10 20:43 ` mikael at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-08-10 20:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from kargl at gcc dot gnu dot org  2010-08-10 20:19 -------
The patch in comment #4 passes regression testing on x86_64-*-freebsd.


-- 


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


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

* [Bug fortran/45244] Incorrect passing of character string array argument triggers an internal compiler error
  2010-08-10  2:07 [Bug fortran/45244] New: Incorrect passing of character string array argument triggers an internal compiler error Eric dot Zurcher at csiro dot au
                   ` (3 preceding siblings ...)
  2010-08-10 20:19 ` kargl at gcc dot gnu dot org
@ 2010-08-10 20:43 ` mikael at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: mikael at gcc dot gnu dot org @ 2010-08-10 20:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mikael at gcc dot gnu dot org  2010-08-10 20:42 -------
(In reply to comment #3)
> Might as well confirm the bug.
> 
> This patch stops the segmentation fault, but I do not know
> if it is the correct fix.
> 
I think the correct fix here is to take the array spec (and maybe the pointer
attribute as well) from the derived type component instead of the symbol. 


-- 


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


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

end of thread, other threads:[~2010-08-10 20:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-10  2:07 [Bug fortran/45244] New: Incorrect passing of character string array argument triggers an internal compiler error Eric dot Zurcher at csiro dot au
2010-08-10  2:17 ` [Bug fortran/45244] " Eric dot Zurcher at csiro dot au
2010-08-10  2:37 ` kargl at gcc dot gnu dot org
2010-08-10 17:50 ` kargl at gcc dot gnu dot org
2010-08-10 20:19 ` kargl at gcc dot gnu dot org
2010-08-10 20:43 ` mikael 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).