This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran, 4.5 Regression] PR 40822: Internal compiler error when Fortran intrinsic LEN referenced before explicit declaration
On Thu, Jul 23, 2009 at 05:53:37PM +0200, Janus Weil wrote:
> 2009/7/23 Tobias Burnus <burnus@net-b.de>:
> > Janus Weil wrote:
> >> here is a close-to-obvious two-line patch, fixing a regression which
> >> was introduced by one of my earlier ProcPtr patches.
> > I have not fully thought about the patch. But if I read
> >
> > + ? ? ?if (formal_arg->sym->ts.type == BT_CHARACTER)
> > + ? ? ? formal_arg->sym->ts.cl = gfc_get_charlen ();
> > +
> >
> >
> > I wonder whether this does not just allocate space for the character
> > length data, without actually properly initializing the struct.
>
> I guess the cl structure here is at least initialized in the sense
> that it is zeroed, and there is no junk data in there.
>
> The reason that I don't initialize cl->length is that
> "cl->length==NULL" is equivalent to an assumed-length string, right?
I believe that you're correct. But, with the deferred type
parameter patch that I've been work on, cl->length==NULL
also means the CHARACTER(len=:) entity hasn't been allocated
(or assigned to).
program t
character(len=:) str ! cl->length==NULL
str = 'abc' ! implicit allocation of len=3
allocate(character(len=2) :: str) ! Illegal, detected by cl->length!=NULL
end program
--
Steve