This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/86437] runtime segfault on Fortran code with large array and -Ofast


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86437

--- Comment #2 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #1)
> WORKSFORME. AFAIR -Ofast implies -fstack-arrays.

Yeah, right, -fstack-arrays is the crucial flag here.


> What is the output of
> 
> ulimit -s
> 
> (kbytes, -s) 65532 for me?

8192

So, yes, I'm hitting the stack size.


However, what is a bit strange is that I get this problem only when putting the
ALLOCATE statement into a subroutine, which returns the allocated array, but
not when allocating directly in the main program. Is this intended behavior?

The documentation says:

"-fstack-arrays

    Adding this option will make the Fortran compiler put all arrays of unknown
size and array temporaries onto stack memory. If your program uses very large
local arrays it is possible that you will have to extend your runtime limits
for stack memory on some operating systems."


This mentions 'local arrays', and I was also assuming that only local arrays
will be put on the stack. In my example, Y1 and Y2 are not local, but declared
in the main program. Only the allocation happens in a subroutine, but the
arrays are returned to the main program via a subroutine argument ...

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]