Bug 21034 - [4.0 only] internal compiler error: in gfc_trans_auto_array_allocation, at fortran/trans-array.c:3036
Summary: [4.0 only] internal compiler error: in gfc_trans_auto_array_allocation, at fo...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.0.2
Assignee: Paul Brook
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2005-04-14 22:33 UTC by Nicolas Girard
Modified: 2005-07-27 12:50 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-06-22 18:51:33


Attachments
Assembler file generated using the -save-temps option (10.00 KB, application/octet-stream)
2005-04-14 22:35 UTC, Nicolas Girard
Details
Source files (87.15 KB, application/x-tgz)
2005-04-15 06:10 UTC, Nicolas Girard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Girard 2005-04-14 22:33:25 UTC
Hi, 
I was in the process of translating a program written in f77 into f90 when this 
bug occurred. All I did was to add parameters to a function ; these parameters 
must correspond to the dimensions of arrays, as I want to allocate memory to 
them dynamically. 
 
I declared my arrays like: 
 
real*8,dimension(n1,n2) tab1, tab2 
 
and n1 and n2 are the two variables I added in the parameters of my function. 
 
 
"$ gfc --version" gives: 
GNU Fortran 95 (GCC 4.1.0 20050413 (experimental)) 
 
Compilation options: 
-ffixed-line-length-132 -Wall -static 
 
I'm completely stuck because of this problem, therefore if you had the 
slightest idea, even just to get round this, I'd be *much* interested... 
 
Many thanks in advance !
Comment 1 Nicolas Girard 2005-04-14 22:35:09 UTC
Created attachment 8637 [details]
Assembler file generated using the -save-temps option
Comment 2 Andrew Pinski 2005-04-14 23:33:10 UTC
Could you attach the .f90 file?
Comment 3 Nicolas Girard 2005-04-15 06:09:12 UTC
Sure. 
Actually the main file is a .F file. The tgz I'm about to attach contain the 
following files: 
 
- main.F : main file 
- guess.h  params.h  pinch_complet.h  prec.h: included by the preprocessor 
- routines.h.ok : when renamed to routines.h, the program compiles fine 
- routines.h.bug: when renamed to routines.h, causes the bug to appear 
 
"$ diff routines.*" gives: 
408c408 
<         subroutine solution(n,xf,fg,h1,h2,beta,pas,tolerance,nmax,xav) 
--- 
>         subroutine solution(xf,fg,h1,h2,beta,pas,tolerance,nmax,xav) 
438c438 
<         parameter (n1=5,n2=5,ndims=10) 
--- 
>         parameter (n1=5,n2=5,n=1024,ndims=10) 
 
All I did was to add "n" as a new parameter of the solution() subroutine ; here 
the call to solution() is unchanged but adding a variable corresponding to n in 
the function call changes nothing, the bug still appears. 
 
Thanks again, 
cheers  
Comment 4 Nicolas Girard 2005-04-15 06:10:21 UTC
Created attachment 8639 [details]
Source files
Comment 5 Francois-Xavier Coudert 2005-04-15 08:30:09 UTC
Reduced testcase is:

$ cat pr21034.f 
        subroutine solution(n)
        implicit none
        integer n
        real dte(n)
        save
        print *, dte
        end
$ gfortran -c pr21034.f
pr21034.f: In function ‘solution’:
pr21034.f:4: internal compiler error: in gfc_trans_auto_array_allocation, at
fortran/trans-array.c:3036


Please note that if "print *,dte" is replaced by any other statement using dte
(such as "dte(:) = 0" or "call anothersub(dte)"), the bug is the same. Removing
this line, removing the "save" statement or make n a parameter lead to correct
compilation.
Comment 6 GCC Commits 2005-06-22 15:34:09 UTC
Subject: Bug 21034

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pbrook@gcc.gnu.org	2005-06-22 15:34:02

Modified files:
	gcc/fortran    : ChangeLog symbol.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: auto_save_1.f90 

Log message:
	2005-06-22 Paul Brook  <paul@codesourcery.com>
	
	PR fortran/21034
	* symbol.c (gfc_is_var_automatic): New function.
	(save_symbol): Use it.
	testsuite/
	* gfortran.dg/auto_save_1.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.470&r2=1.471
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/symbol.c.diff?cvsroot=gcc&r1=1.29&r2=1.30
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5670&r2=1.5671
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/auto_save_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 Paul Brook 2005-06-22 16:00:02 UTC
Fixed.
Comment 8 Francois-Xavier Coudert 2005-06-22 16:03:33 UTC
What about 4.0? Right now, we've been trying to keep all patches applied on both
branches. Doesn't this bug happen on 4.0 too?
Comment 9 Paul Brook 2005-06-22 18:51:12 UTC
Reopening until 4.0 is unforzen and the patch applied there
Comment 10 GCC Commits 2005-07-15 15:21:31 UTC
Subject: Bug 21034

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	pbrook@gcc.gnu.org	2005-07-15 15:21:21

Modified files:
	gcc/fortran    : ChangeLog symbol.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: auto_save_1.f90 

Log message:
	2005-07-15 Paul Brook  <paul@codesourcery.com>
	
	Backport form mainline.
	2005-06-22 Paul Brook  <paul@codesourcery.com>
	PR fortran/21034
	* symbol.c (gfc_is_var_automatic): New function.
	(save_symbol): Use it.
	testsuite/
	* gfortran.dg/auto_save_1.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.335.2.90&r2=1.335.2.91
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/symbol.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.26.2.1&r2=1.26.2.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.277&r2=1.5084.2.278
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/auto_save_1.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.8.1

Comment 11 Paul Brook 2005-07-15 15:22:51 UTC
Fix applied to 4.0-branch.
Comment 12 Volker Reichelt 2005-07-27 12:50:14 UTC
*** Bug 23091 has been marked as a duplicate of this bug. ***