public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/37626]  New: Internal compiler error triggered by gfortran PACK intrinsic
@ 2008-09-23 18:18 townsend at astro dot wisc dot edu
  2008-09-23 18:50 ` [Bug fortran/37626] " dominiq at lps dot ens dot fr
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: townsend at astro dot wisc dot edu @ 2008-09-23 18:18 UTC (permalink / raw)
  To: gcc-bugs

The sample code below produces the following internal compiler error:

unique_A.f90: In function 'unique_a':
unique_A.f90:42: internal compiler error: Segmentation fault

The error seems to be associated with use of the PACK() intrinsic.

--CUT HERE--
function unique_A (x, sorted) result (x_unique)

  character(*), dimension(:), intent(in)       :: x
  logical, intent(in), optional                :: sorted
  character(LEN(x)), dimension(:), allocatable :: x_unique

  logical                                      :: sorted_
  character(LEN(x)), dimension(SIZE(x))        :: x_sorted
  integer                                      :: n_x
  logical, dimension(SIZE(x))                  :: mask

  integer, external                            :: b3ss_index

! Set up sorted_

  if(PRESENT(sorted)) then
     sorted_ = sorted
  else
     sorted_ = .FALSE.
  endif

! If necessary, sort x

  if(sorted_) then
     x_sorted = x
  else
     x_sorted = x(b3ss_index(x))
  endif

! Set up the unique array

  n_x = SIZE(x)

  mask = (/.TRUE.,x_sorted(2:n_x) /= x_sorted(1:n_x-1)/)

  allocate(x_unique(COUNT(mask)))

  x_unique = PACK(x_sorted, MASK=mask)

! Finish

  return

end function unique_A


-- 
           Summary: Internal compiler error triggered by gfortran PACK
                    intrinsic
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: townsend at astro dot wisc dot edu
 GCC build triplet: x86_64-gentoo-linux
  GCC host triplet: x86_64-gentoo-linux
GCC target triplet: x86_64-gentoo-linux


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


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

* [Bug fortran/37626] Internal compiler error triggered by gfortran PACK intrinsic
  2008-09-23 18:18 [Bug fortran/37626] New: Internal compiler error triggered by gfortran PACK intrinsic townsend at astro dot wisc dot edu
@ 2008-09-23 18:50 ` dominiq at lps dot ens dot fr
  2008-09-23 19:44 ` [Bug fortran/37626] ICE for automatic deallocation of character result variable burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens dot fr @ 2008-09-23 18:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dominiq at lps dot ens dot fr  2008-09-23 18:48 -------
On ppc/intel Darwin9, I get

pr37626.f90: In function 'unique_a':
pr37626.f90:42: internal compiler error: in gfc_conv_descriptor_data_get, at
fortran/trans-array.c:147

with 4.2.3, 4.3.2, and trunk.


-- 


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


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

* [Bug fortran/37626] ICE for automatic deallocation of character result variable
  2008-09-23 18:18 [Bug fortran/37626] New: Internal compiler error triggered by gfortran PACK intrinsic townsend at astro dot wisc dot edu
  2008-09-23 18:50 ` [Bug fortran/37626] " dominiq at lps dot ens dot fr
@ 2008-09-23 19:44 ` burnus at gcc dot gnu dot org
  2008-09-24  7:04 ` burnus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-09-23 19:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2008-09-23 19:43 -------
It fails for the following assert:

gfc_conv_descriptor_data_get (tree desc)
{
  tree field, type, t;

  type = TREE_TYPE (desc);
  gcc_assert (GFC_DESCRIPTOR_TYPE_P (type));


Reduced test case:

function unique_A (x) result (x_unique)
  implicit none
  character(*), dimension(:), intent(in)       :: x
  character(LEN(x)), dimension(:), allocatable :: x_unique
  character(LEN(x)), dimension(5)              :: x_sorted
  logical, dimension(4)                        :: mask
  mask = (/ x_sorted(2:5) /= x_sorted(1:4) /)
  allocate(x_unique(COUNT(mask)))
end function unique_A

If one one changes the program to "function x_unique(x)", i.e. sym ==
sym->result, it works. The same is true if the character length is explicitly
set for x_unique (or for x, which implies the latter).

Debugging shows the following call tree for "x_unique":
  #0 gfc_conv_descriptor_data_get
  #1 gfc_trans_dealloc_allocated
  #2 gfc_trans_deferred_array
Thus the ICE happens for the automatic deallocation of "x_unique". But as
x_unique is a result variable that should not happen!

Patch:

--- trans-array.c       (Revision 140615)
+++ trans-array.c       (Arbeitskopie)
@@ -5754,7 +5754,7 @@ gfc_trans_deferred_array (gfc_symbol * s
       gfc_add_expr_to_block (&fnblock, tmp);
     }

-  if (sym->attr.allocatable && !sym->attr.save)
+  if (sym->attr.allocatable && !sym->attr.save && !sym->attr.result)
     {
       tmp = gfc_trans_dealloc_allocated (sym->backend_decl);
       gfc_add_expr_to_block (&fnblock, tmp);


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu dot
                   |                            |org
OtherBugsDependingO|                            |32834
              nThis|                            |
         AssignedTo|unassigned at gcc dot gnu   |burnus at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
  GCC build triplet|x86_64-gentoo-linux         |
   GCC host triplet|x86_64-gentoo-linux         |
 GCC target triplet|x86_64-gentoo-linux         |
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|0000-00-00 00:00:00         |2008-09-23 19:43:30
               date|                            |
            Summary|Internal compiler error     |ICE for automatic
                   |triggered by gfortran PACK  |deallocation of character
                   |intrinsic                   |result variable


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


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

* [Bug fortran/37626] ICE for automatic deallocation of character result variable
  2008-09-23 18:18 [Bug fortran/37626] New: Internal compiler error triggered by gfortran PACK intrinsic townsend at astro dot wisc dot edu
  2008-09-23 18:50 ` [Bug fortran/37626] " dominiq at lps dot ens dot fr
  2008-09-23 19:44 ` [Bug fortran/37626] ICE for automatic deallocation of character result variable burnus at gcc dot gnu dot org
@ 2008-09-24  7:04 ` burnus at gcc dot gnu dot org
  2008-09-25 16:21 ` burnus at gcc dot gnu dot org
  2008-09-25 16:22 ` burnus at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-09-24  7:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2008-09-24 07:02 -------
Subject: Bug 37626

Author: burnus
Date: Wed Sep 24 07:01:18 2008
New Revision: 140624

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

        PR fortran/37626
        * trans-array.c (gfc_trans_deferred_array): Don't auto-deallocate
        result variables.

2008-09-24  Tobias Burnus  <burnus@net-b.de>

        PR fortran/37626
        * gfortran.dg/allocatable_function_4.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/allocatable_function_4.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/37626] ICE for automatic deallocation of character result variable
  2008-09-23 18:18 [Bug fortran/37626] New: Internal compiler error triggered by gfortran PACK intrinsic townsend at astro dot wisc dot edu
                   ` (2 preceding siblings ...)
  2008-09-24  7:04 ` burnus at gcc dot gnu dot org
@ 2008-09-25 16:21 ` burnus at gcc dot gnu dot org
  2008-09-25 16:22 ` burnus at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-09-25 16:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2008-09-25 16:20 -------
Subject: Bug 37626

Author: burnus
Date: Thu Sep 25 16:18:45 2008
New Revision: 140667

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

        PR fortran/37626
        * trans-array.c (gfc_trans_deferred_array): Don't
        * auto-deallocate
        result variable.

2008-09-25  Tobias Burnus  <burnus@net-b.de>

        PR fortran/37626
        * gfortran.dg/allocatable_function_4.f90: New test.


Added:
   
branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/allocatable_function_4.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/trans-array.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/37626] ICE for automatic deallocation of character result variable
  2008-09-23 18:18 [Bug fortran/37626] New: Internal compiler error triggered by gfortran PACK intrinsic townsend at astro dot wisc dot edu
                   ` (3 preceding siblings ...)
  2008-09-25 16:21 ` burnus at gcc dot gnu dot org
@ 2008-09-25 16:22 ` burnus at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-09-25 16:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2008-09-25 16:21 -------
FIXED on the trunk (4.4.0) and on the 4.3 branch.

Thanks for the bug report!


-- 

burnus at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2008-09-25 16:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-23 18:18 [Bug fortran/37626] New: Internal compiler error triggered by gfortran PACK intrinsic townsend at astro dot wisc dot edu
2008-09-23 18:50 ` [Bug fortran/37626] " dominiq at lps dot ens dot fr
2008-09-23 19:44 ` [Bug fortran/37626] ICE for automatic deallocation of character result variable burnus at gcc dot gnu dot org
2008-09-24  7:04 ` burnus at gcc dot gnu dot org
2008-09-25 16:21 ` burnus at gcc dot gnu dot org
2008-09-25 16:22 ` burnus 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).