Automatic arrays and intrinsic array operations: to use or not to use?

I am not sure. This is what I obtained by valgrin ./a.out:

 Initialize
 Loop
 Succeed
 MATMUL
==324261== Warning: client switching stacks?  SP change: 0x1ffeffb4e0 --> 0x1ffd176ce0
==324261==          to suppress, use: --max-stackframe=32000000 or greater
==324261== Invalid write of size 8
==324261==    at 0x4050E9: MAIN__ (test_matmul.f90:47)
==324261==  Address 0x1ffd176ce0 is on thread 1's stack
==324261== 
==324261== Warning: ignored attempt to set SIGKILL handler in sigaction();
==324261==          the SIGKILL signal is uncatchable
==324261== Warning: ignored attempt to set SIGSTOP handler in sigaction();
==324261==          the SIGSTOP signal is uncatchable
==324261== Warning: ignored attempt to set SIGRT32 handler in sigaction();
==324261==          the SIGRT32 signal is used internally by Valgrind
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
a.out              000000000040601A  Unknown               Unknown  Unknown
libpthread-2.31.s  00000000049AF420  Unknown               Unknown  Unknown
a.out              00000000004050E9  Unknown               Unknown  Unknown
a.out              0000000000403822  Unknown               Unknown  Unknown
libc-2.31.so       00000000049E2083  __libc_start_main     Unknown  Unknown
a.out              000000000040372E  Unknown               Unknown  Unknown

and by gdb ./a.out:

Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1".
 Initialize
 Loop
 Succeed
 MATMUL

Program received signal SIGSEGV, Segmentation fault.
0x00000000004050e9 in test_matmul () at test_matmul.f90:47
47	B = matmul(A, A)
(gdb) bt
#0  0x00000000004050e9 in test_matmul () at test_matmul.f90:47
#1  0x0000000000403822 in main ()
#2  0x00007ffff7c85083 in __libc_start_main (main=0x4037f0 <main>, argc=1, argv=0x7fffffff9968, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffff9958)
    at ../csu/libc-start.c:308
#3  0x000000000040372e in _start ()
(gdb) 

It seems to me that the segfault occurred when writing the result of matmul to B, but I am not sure.
(BTW, why doesn’t ifort print the call stack of the error even when -g is specified?)

This sounds truly interesting. It is something I hope for. How could we make it happen?