Bug 20361 - -fmax-stack-var-size=N not working for equivalence
Summary: -fmax-stack-var-size=N not working for equivalence
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Tobias Schlüter
URL:
Keywords: wrong-code
Depends on:
Blocks: 20405
  Show dependency treegraph
 
Reported: 2005-03-07 16:33 UTC by Paul Thomas
Modified: 2005-03-12 21:56 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-03-12 00:39:45


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Thomas 2005-03-07 16:33:08 UTC
The enclosed example causes a segmentation fault at runtime under Cygwin.  
Reducing the length of pool1 by 1 allows it to run.  This length looks like 
2^18 less a header block so paging/memory/stack was suspected.  Note this does 
not occur in Linux or native Windows versions of gfortran. 

Setting -fmax-stack-var-size appropriately makes no difference but
d:/irun/bin/gfortran -Wl,--stack=2100000 fixes the problem.

-fmax-stack-var-size seems to work for non-equivalence variables but is broken 
for equivalenced variables - see correspondence on the list between myself and 
A.Pinskia dated 6-7 March 2005 under the subject: Re: Equivalence segfault in 
TEST_FPU.F90

Test programme and output:
__________________________

program test_equivalence
 real*8      ::  pool1(260105),pool2(1)
 equivalence (pool1,pool2)
end program test_equivalence

$ d:/irun/bin/gfortran -v test_prequi.f90
Driving: d:/irun/bin/gfortran -v test_prequi.f90 -lgfortranbegin -lgfortran
Using built-in specs.
Configured with: ../gcc/configure --with-mpfr=/gmp-gcc4 --with-gmp=/gmp-gcc4 -en
able-languages=c,f95 --prefix=/cygdrive/d/irun
Thread model: single
gcc version 4.0.0 20050129 (experimental)
/cygdrive/d/irun/libexec/gcc/i686-pc-cygwin/4.0.0/f951.exe test_prequi.f90 -qui
et -dumpbase test_prequi.f90 -mtune=pentiumpro -auxbase test_prequi -version -o
/cygdrive/c/DOCUME~1/PAULTH~1/LOCALS~1/Temp/cc1r1KUq.s
GNU F95 version 4.0.0 20050209 (experimental) (i686-pc-cygwin)
compiled by GNU C version 4.0.0 20050131 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
as -o /cygdrive/c/DOCUME~1/PAULTH~1/LOCALS~1/Temp/ccK4DcrJ.o /cygdrive/c/DOCUME
~1/PAULTH~1/LOCALS~1/Temp/cc1r1KUq.s
/cygdrive/d/irun/libexec/gcc/i686-pc-cygwin/4.0.0/collect2.exe -Bdynamic --dll-
search-prefix=cyg /lib/crt0.o -L/cygdrive/d/irun/lib/gcc/i686-pc-cygwin/4.0.0 -L
/cygdrive/d/irun/lib/gcc/i686-pc-cygwin/4.0.0/../../.. /cygdrive/c/DOCUME~1/PAUL
TH~1/LOCALS~1/Temp/ccK4DcrJ.o -lgfortranbegin -lgfortran -lgcc -lcygwin -luser32
-lkernel32 -ladvapi32 -lshell32 -lgcc

PaulThomas@Paul /cygdrive/d/gfortran
$ ./a
Segmentation fault (core dumped)
Comment 1 Andrew Pinski 2005-03-07 16:35:24 UTC
Just I note, my last name is Pinski, not Pinskia, the a is for my first name.

Confirmed.
Comment 2 GCC Commits 2005-03-12 21:44:53 UTC
Subject: Bug 20361

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tobi@gcc.gnu.org	2005-03-12 21:44:44

Modified files:
	gcc/fortran    : ChangeLog trans-array.c trans-array.h 
	                 trans-common.c trans-decl.c trans.h 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: largeequiv_1.f90 

Log message:
	fortran/
	PR fortran/20361
	* trans-array.c (gfc_stack_space_left): Remove unused variable.
	(gfc_can_put_var_on_stack): Move to trans-decl.c, remove #if 0'ed
	code.
	* trans-array.h (gfc_stack_space_left, gfc_can_put_var_on_stack):
	Remove declaration / prototype.
	* trans-common.c (build_equiv_decl): Give union a name.  Check if
	it can be put on the stack.
	* trans-decl.c (gfc_stack_space_left): Move function here.
	(gfc_build_qualified_array): Fix comment typo.
	* trans.h (gfc_put_var_on_stack): Add prototype.
	
	testsuite/
	PR fortran/20361
	* gfortran.dg/largeequiv_1.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.348&r2=1.349
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-array.c.diff?cvsroot=gcc&r1=1.39&r2=1.40
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-array.h.diff?cvsroot=gcc&r1=1.7&r2=1.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-common.c.diff?cvsroot=gcc&r1=1.23&r2=1.24
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-decl.c.diff?cvsroot=gcc&r1=1.54&r2=1.55
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans.h.diff?cvsroot=gcc&r1=1.23&r2=1.24
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5151&r2=1.5152
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/largeequiv_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 3 GCC Commits 2005-03-12 21:51:04 UTC
Subject: Bug 20361

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	tobi@gcc.gnu.org	2005-03-12 21:50:51

Modified files:
	gcc/fortran    : ChangeLog trans-array.c trans-array.h 
	                 trans-common.c trans-decl.c trans.h 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: largeequiv_1.f90 

Log message:
	fortran/
	PR fortran/20361
	* trans-array.c (gfc_stack_space_left): Remove unused variable.
	(gfc_can_put_var_on_stack): Move to trans-decl.c, remove #if 0'ed
	code.
	* trans-array.h (gfc_stack_space_left, gfc_can_put_var_on_stack):
	Remove declaration / prototype.
	* trans-common.c (build_equiv_decl): Give union a name.  Check if
	it can be put on the stack.
	* trans-decl.c (gfc_stack_space_left): Move function here.
	(gfc_build_qualified_array): Fix comment typo.
	* trans.h (gfc_put_var_on_stack): Add prototype.
	
	testsuite/
	PR fortran/20361
	* gfortran.dg/largeequiv_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.9&r2=1.335.2.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-array.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.39&r2=1.39.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-array.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.7&r2=1.7.18.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-common.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.23&r2=1.23.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-decl.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.54&r2=1.54.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.23&r2=1.23.2.1
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.37&r2=1.5084.2.38
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/largeequiv_1.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 4 Tobias Schlüter 2005-03-12 21:56:22 UTC
Fixed.