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

--- Comment #3 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #2)
> (In reply to Dominique d'Humieres from comment #1)
> > The problem seems more serious.
> > 
> > type t
> >   character(len=:, kind=4), pointer :: str2
> > end type t
> > type(t) :: var
> > character(len=:, kind=4), pointer :: str
> > 
> > print *, kind(str), kind(var%str2)
> > str(1:1) = 4_"a"
> > end
> > 
> > result
> > 
> > % ./a.out 
> >            4           4
> 
> Yes, there is a serious problem with the Fortran code!
> 
> str is an undefined pointer.  The line 'str(1:1) = 4_"a"'
> is invalid.

In fact, after a quick scan of the Fortran 2018 standard.
The PR is likely invalid.  Allocation on assignment applies
to ALLOCATABLE variables not undefined or disassociated
pointers.

Yep.  Definitely invalid.

Fortran 2018,
10.2.1.2 Intrinsic assignment statement
p. 160

If the variable is a pointer, it shall be associated with a definable
target such that the type, type parameters, and shape of the target and
expr conform.

Reply via email to