https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90890
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Sat, Jun 15, 2019 at 11:08:43PM +0000, bharat.mahajan at hotmail dot com
wrote:
>
> I forgot to mention that code runs with no issues with ifort. Second, then why
> the following code works with gfortran?
The Fortran standard does not require a Fortran processor (i.e.,
the compiler) to detect and report that you are using an undefined
entity.
> program test
> implicit none
> real, dimension(:), allocatable :: a
> integer :: b
> a = [a, 2.0]
What value does 'a' have on the right side of the above
expression?
The correct way to write the above would have either
been to assign something to 'a' prior to using on the
RHS above or writing
if (allocated(a)) a = [a, 2.0]
> !b = -100
> end program test
> ---
>
> I am not sure I would say 'a' is not defined.
The Fortran standard decides what is defined and undefined.
From F2018
19.6.2 Variables that are always defined
Zero-sized arrays and zero-length strings are always defined.
19.6.3 Variables that are initially defined
The following variables are initially defined:
(1) variables specified to have initial values by DATA statements;
(2) variables specified to have initial values by type declaration
statements;
(3) nonpointer default-initialized subcomponents of saved variables
that do not have the ALLOCATABLE or POINTER attribute;
(4) pointers specified to be initially associated with a variable
that is initially defined;
(5) variables that are always defined;
(6) variables with the BIND attribute that are initialized by means
other than Fortran.
19.6.4 Variables that are initially undefined
Variables that are not initially defined are initially undefined.
Your 'a' is undefined.