This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/86437] runtime segfault on Fortran code with large array and -Ofast
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 09 Jul 2018 09:53:48 +0000
- Subject: [Bug middle-end/86437] runtime segfault on Fortran code with large array and -Ofast
- Auto-submitted: auto-generated
- References: <bug-86437-4@http.gcc.gnu.org/bugzilla/>
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 ...