public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/27980]  New: Wrong allocation for zero-sized function result
@ 2006-06-09 17:47 tkoenig at gcc dot gnu dot org
  2006-06-09 18:30 ` [Bug fortran/27980] " tkoenig at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2006-06-09 17:47 UTC (permalink / raw)
  To: gcc-bugs

>From a posting to comp.lang.fortran:

program xint_func
  implicit none
  integer, parameter :: n=3,ii(n)=(/2,0,-1/)
  integer            :: i
  character(len=80)  :: line
  do i=1,n
     write (line,'(10I5)'), int_func(ii(i))
  end do
contains
  function int_func(n) result(ivec)
    integer, intent(in) :: n
    integer             :: ivec(n)
    integer             :: i
    if (n > 0) then
       forall (i=1:n) ivec(i) = i
    end if
  end function int_func
end program xint_func
$ gfortran foo.f90
$ ./a.out
Fortran runtime error: Attempt to allocate a negative amount of memory.
$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../../gcc/trunk/configure --prefix=/home/ig25
--enable-languages=c,fortran
Thread model: posix
gcc version 4.2.0 20060525 (experimental)

I'm looking into this.


-- 
           Summary: Wrong allocation for zero-sized function result
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org


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


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

* [Bug fortran/27980] Wrong allocation for zero-sized function result
  2006-06-09 17:47 [Bug fortran/27980] New: Wrong allocation for zero-sized function result tkoenig at gcc dot gnu dot org
@ 2006-06-09 18:30 ` tkoenig at gcc dot gnu dot org
  2006-06-12 22:04 ` 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 @ 2006-06-09 18:30 UTC (permalink / raw)
  To: gcc-bugs



-- 

tkoenig at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tkoenig at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-06-09 18:18:24
               date|                            |


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


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

* [Bug fortran/27980] Wrong allocation for zero-sized function result
  2006-06-09 17:47 [Bug fortran/27980] New: Wrong allocation for zero-sized function result tkoenig at gcc dot gnu dot org
  2006-06-09 18:30 ` [Bug fortran/27980] " tkoenig at gcc dot gnu dot org
@ 2006-06-12 22:04 ` tkoenig at gcc dot gnu dot org
  2006-06-12 23:00 ` kargl at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2006-06-12 22:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from tkoenig at gcc dot gnu dot org  2006-06-12 21:57 -------
Created an attachment (id=11657)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11657&action=view)
patch

Here's a patch (regression-tested).

I'm not 100% sure this is the most elegant method, though.


-- 


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


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

* [Bug fortran/27980] Wrong allocation for zero-sized function result
  2006-06-09 17:47 [Bug fortran/27980] New: Wrong allocation for zero-sized function result tkoenig at gcc dot gnu dot org
  2006-06-09 18:30 ` [Bug fortran/27980] " tkoenig at gcc dot gnu dot org
  2006-06-12 22:04 ` tkoenig at gcc dot gnu dot org
@ 2006-06-12 23:00 ` kargl at gcc dot gnu dot org
  2006-06-13 19:15 ` patchapp at dberlin dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu dot org @ 2006-06-12 23:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from kargl at gcc dot gnu dot org  2006-06-12 22:56 -------
*** Bug 28006 has been marked as a duplicate of this bug. ***


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tobias dot burnus at physik
                   |                            |dot fu-berlin dot de


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


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

* [Bug fortran/27980] Wrong allocation for zero-sized function result
  2006-06-09 17:47 [Bug fortran/27980] New: Wrong allocation for zero-sized function result tkoenig at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-06-12 23:00 ` kargl at gcc dot gnu dot org
@ 2006-06-13 19:15 ` patchapp at dberlin dot org
  2006-06-19 22:42 ` [Bug fortran/27980] [4.1 only] " fxcoudert at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: patchapp at dberlin dot org @ 2006-06-13 19:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from patchapp at dberlin dot org  2006-06-13 19:15 -------
Subject: Bug number PR 27980

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00708.html


-- 


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


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

* [Bug fortran/27980] [4.1 only] Wrong allocation for zero-sized function result
  2006-06-09 17:47 [Bug fortran/27980] New: Wrong allocation for zero-sized function result tkoenig at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-06-13 19:15 ` patchapp at dberlin dot org
@ 2006-06-19 22:42 ` fxcoudert at gcc dot gnu dot org
  2006-06-19 23:07 ` fxcoudert at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-06-19 22:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from fxcoudert at gcc dot gnu dot org  2006-06-19 22:29 -------
Was fixed on mainline by

r114677 | tkoenig | 2006-06-15 12:30:09 +0200 (Thu, 15 Jun 2006) | 23 lines

2006-06-15  Thomas Koenig <Thomas.Koenig@online.de>

        * trans-array.h (gfc_trans_create_temp_array):  Add bool
        argument.
        * trans-arrray.c (gfc_trans_create_temp_array): Add extra
        argument "function" to show if we are translating a function.
        If we are translating a function, perform checks whether
        the size along any argument is negative.  In that case,
        allocate size 0.
        (gfc_trans_allocate_storage):  Add function argument (as
        false) to gfc_trans_create_temp_array call.
        * trans-expr.c (gfc_conv_function_call):  Add function
        argument (as true) to gfc_trans_create_temp_array call.
        * trans-stmt.c (gfc_conv_elemental_dependencies): Add
        function argument (as false) to gfc_trans_create_temp_array
        call.
        * trans-intrinsic.c:  Likewise.

2006-06-15  Thomas Koenig <Thomas.Koenig@online.de>

        * gfortran.dg/allocate_zerosize_2.f90:  New test case.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
      Known to fail|                            |4.1.2
      Known to work|                            |4.2.0
            Summary|Wrong allocation for zero-  |[4.1 only] Wrong allocation
                   |sized function result       |for zero-sized function
                   |                            |result
   Target Milestone|---                         |4.1.2


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


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

* [Bug fortran/27980] [4.1 only] Wrong allocation for zero-sized function result
  2006-06-09 17:47 [Bug fortran/27980] New: Wrong allocation for zero-sized function result tkoenig at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-06-19 22:42 ` [Bug fortran/27980] [4.1 only] " fxcoudert at gcc dot gnu dot org
@ 2006-06-19 23:07 ` fxcoudert at gcc dot gnu dot org
  2006-07-15 21:47 ` tkoenig at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-06-19 23:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2006-06-19 22:45 -------
The backport of that patch is not trivial, since the mainline patch depends on
Erik E.'s allocatable function result patch, which was never included in 4.1. I
don't think it's difficult to backport either, but since it's your patch,
Thomas, I'll let you do it when you have more time.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu dot
                   |                            |org


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


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

* [Bug fortran/27980] [4.1 only] Wrong allocation for zero-sized function result
  2006-06-09 17:47 [Bug fortran/27980] New: Wrong allocation for zero-sized function result tkoenig at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-06-19 23:07 ` fxcoudert at gcc dot gnu dot org
@ 2006-07-15 21:47 ` tkoenig at gcc dot gnu dot org
  2006-07-16 10:12 ` tkoenig at gcc dot gnu dot org
  2006-07-16 10:12 ` tkoenig at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2006-07-15 21:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from tkoenig at gcc dot gnu dot org  2006-07-15 21:47 -------
Created an attachment (id=11893)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11893&action=view)
Patch for 4.1

Adapted patch for 4.1.


-- 


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


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

* [Bug fortran/27980] [4.1 only] Wrong allocation for zero-sized function result
  2006-06-09 17:47 [Bug fortran/27980] New: Wrong allocation for zero-sized function result tkoenig at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2006-07-15 21:47 ` tkoenig at gcc dot gnu dot org
@ 2006-07-16 10:12 ` tkoenig at gcc dot gnu dot org
  2006-07-16 10:12 ` tkoenig at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2006-07-16 10:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from tkoenig at gcc dot gnu dot org  2006-07-16 10:12 -------
Fixed on mainline and 4.1.  Closing.


-- 

tkoenig at gcc dot gnu dot org changed:

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


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


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

* [Bug fortran/27980] [4.1 only] Wrong allocation for zero-sized function result
  2006-06-09 17:47 [Bug fortran/27980] New: Wrong allocation for zero-sized function result tkoenig at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2006-07-16 10:12 ` tkoenig at gcc dot gnu dot org
@ 2006-07-16 10:12 ` tkoenig at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2006-07-16 10:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from tkoenig at gcc dot gnu dot org  2006-07-16 10:12 -------
Subject: Bug 27980

Author: tkoenig
Date: Sun Jul 16 10:11:57 2006
New Revision: 115496

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115496
Log:
2006-07-16  Thomas Koenig  <Thomas.Koenig@online.de>

        PR fortran/27980
        Backport from mainline
        * trans-array.h (gfc_trans_allocate_temp_array):  Add bool
        argument.
        * trans-array.c (gfc_trans_allocate_temp_array): Add extra
        argument "function" to show if we are translating a function.
        If we are translating a function, perform checks whether
        the size along any argument is negative.  In that case,
        allocate size 0.
        (gfc_trans_array_constructor):  Add funciton argument (as
        false) to gfc_trans_allocate_temp_array.
        (gfc_conv_loop_setup):  Likewise.
        * trans-expr.c (gfc_trans_function_call): Add funciton
        argument (as true) to gfc_trans_allocate_temp_array.
        * trans-stmt.c (gfc_conv_elemental_dependencies): Add funciton
        argument (as false) to gfc_trans_allocate_temp_array.
        * trans-intrinsic.c (gfc_conv_intrinsic_array_transfer):
        Likewise.

2006-07-16  Thomas Koenig  <Thomas.Koenig@online.de>

        PR fortran/27980
        * gfortran.dg/allocate_zerosize_2.f90:  New test.


Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/allocate_zerosize_2.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/trans-array.c
    branches/gcc-4_1-branch/gcc/fortran/trans-array.h
    branches/gcc-4_1-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_1-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_1-branch/gcc/fortran/trans-stmt.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


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

end of thread, other threads:[~2006-07-16 10:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-09 17:47 [Bug fortran/27980] New: Wrong allocation for zero-sized function result tkoenig at gcc dot gnu dot org
2006-06-09 18:30 ` [Bug fortran/27980] " tkoenig at gcc dot gnu dot org
2006-06-12 22:04 ` tkoenig at gcc dot gnu dot org
2006-06-12 23:00 ` kargl at gcc dot gnu dot org
2006-06-13 19:15 ` patchapp at dberlin dot org
2006-06-19 22:42 ` [Bug fortran/27980] [4.1 only] " fxcoudert at gcc dot gnu dot org
2006-06-19 23:07 ` fxcoudert at gcc dot gnu dot org
2006-07-15 21:47 ` tkoenig at gcc dot gnu dot org
2006-07-16 10:12 ` tkoenig at gcc dot gnu dot org
2006-07-16 10:12 ` tkoenig 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).