Bug 81701 - -fstack-arrays hehavior does not match documentation
Summary: -fstack-arrays hehavior does not match documentation
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: documentation
Depends on:
Blocks: 68829
  Show dependency treegraph
 
Reported: 2017-08-03 15:55 UTC by Thomas Koenig
Modified: 2017-09-13 16:37 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2017-08-03 15:55:33 UTC
The docs say

     Adding this option will make the Fortran compiler put all local
     arrays, even those of unknown size onto stack memory.

This is not what happens at the moment.  Look at

module x
contains
  subroutine a(n,r)
    real, dimension(10000) :: arr
    real :: r
    call random_number(arr)
    r = sum(arr)
  end subroutine a
end module x

which, when translated, gets us

a (integer(kind=4) & restrict n, real(kind=4) & restrict r)
{
  static real(kind=4) arr[10000];

  {
    struct array1_real(kind=4) parm.0;

...

We should change the documented or the actual behavior, or both :)
Comment 1 Richard Biener 2017-08-04 07:54:09 UTC
Documentation.  Promoting to .data is better but doesn't work for recursive functions.
Comment 2 Thomas Koenig 2017-08-07 16:43:37 UTC
Author: tkoenig
Date: Mon Aug  7 16:43:05 2017
New Revision: 250923

URL: https://gcc.gnu.org/viewcvs?rev=250923&root=gcc&view=rev
Log:
2017-08-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/68829
	* doc/invoke.texi: Document change in behvaior for -Ofast for
	Fortran.

2017-08-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/68829
	PR fortran/81701
	* options.c: Make -Ofast honor -fmax-stack-var-size.
	* invoke.texi: Document change.

2017-08-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/68829
	PR fortran/81701
	* gfortran.dg/o_fast_stacksize.90:  New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/o_fast_stacksize.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/doc/invoke.texi
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/options.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Thomas Koenig 2017-08-07 16:44:46 UTC
Fixed the docs, closing.
Comment 4 Aldy Hernandez 2017-09-13 16:37:03 UTC
Author: aldyh
Date: Wed Sep 13 16:36:30 2017
New Revision: 252326

URL: https://gcc.gnu.org/viewcvs?rev=252326&root=gcc&view=rev
Log:
2017-08-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/68829
	* doc/invoke.texi: Document change in behvaior for -Ofast for
	Fortran.

2017-08-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/68829
	PR fortran/81701
	* options.c: Make -Ofast honor -fmax-stack-var-size.
	* invoke.texi: Document change.

2017-08-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/68829
	PR fortran/81701
	* gfortran.dg/o_fast_stacksize.90:  New test.

Added:
    branches/range-gen2/gcc/testsuite/gfortran.dg/o_fast_stacksize.f90
Modified:
    branches/range-gen2/gcc/ChangeLog
    branches/range-gen2/gcc/doc/invoke.texi
    branches/range-gen2/gcc/fortran/ChangeLog
    branches/range-gen2/gcc/fortran/options.c
    branches/range-gen2/gcc/testsuite/ChangeLog