This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/29912] Gfortran: string array functions behaving incorrectly...
- From: "pmason at ricardo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Nov 2006 13:27:42 -0000
- Subject: [Bug fortran/29912] Gfortran: string array functions behaving incorrectly...
- References: <bug-29912-13399@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from pmason at ricardo dot com 2006-11-21 13:27 -------
(In reply to comment #5)
> (In reply to comment #4)
> > I'm not 100% certain, but I think it is valid code.
> > I think the "Fortran Standard" states that when assigning
> > string(s) of different lengths that if the lhs string(s) are shorter
> > than the rhs then the strings are truncated accordingly.
> >
> > The statements in the example code:
> >
> > ctemp = temper
> > ctemp = jetter(1,2)
> >
> > are actually equivalent (from a fortran90 point of view) aren't they?.
> >
> > NOTE1: changing the ctemp declaration to be bigger (e.g. len=514) prevents
> > memory/corruption but assignment still goes wrong.
> >
> > NOTE2: All other f90 compilers I have tried seems to handle this "correctly."
> >
> I will check the standard - it might well be that you are right; what I said
> applies to actual arguments, doen't it?
>
> Paul
>
For the case of acutal (non-return) arguments with different len='s you would
expect it go wrong. I think the main problem here was alluded to in comment #1:
i.e. the fact a TEMP array isn't used for return arg. If it was, then the
statememt "ctemp = jetter(1,2)" would reduce "ctemp = temper" where string
trunctation/padding rules wolud apply.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29912