https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78171
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jvdelisle at gcc dot gnu.org
--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Just for clarification, since checking was called for, internally gfortran
generates the following:
array.data = 0B;
if ((integer(kind=8)) ((real(kind=4)[0:] * restrict) array.data == 0B))
{
_gfortran_runtime_error_at (&"At line 4 of file pr78171.f90"[1]{lb: 1 sz:
1}, &"Allocatable actual argument \'array\' is not allocated"[1]{lb: 1 sz: 1});
}
foo ((real(kind=4)[0:] * restrict) array.data);
The optimizer, which comes after, knows array.dat is NULL. Therefore, no matter
what, _gfortran_runtime_error_at will always be executed. The optimizer also
knows that _gfortran_runtime_error_at does not return, it exits with a status
value of 2.
As a consequence, foo will never be called and it is optimized away.
So this is really not a bug in the compiler.