Consider the following code: program test implicit none character(40) line line = 'Hello World!' write (line, '(i3, 2x, a)') 7, trim(line) print *, line end program With the gfortran compiler (v4.5.1) the output is: 7 7lo World! I would expect the output to be 7 Hello World! -- David
Did you see the responses to your post in c.l.f? It seems that your program is non-conforming. I leave the PR open until either I or someone else has time to verify the conformity of the program.
(In reply to comment #1) > Did you see the responses to your post in c.l.f? > It seems that your program is non-conforming. I > leave the PR open until either I or someone else > has time to verify the conformity of the program. > Sorry. When I looked after I had posted the question there was only one response and that response said it was a bug so I submitted this bug report. Now other people have posted saying that the program is non-conforming.
(In reply to comment #2) > Sorry. When I looked after I had posted the question there was only one > response and that response said it was a bug so I submitted this bug report. > Now other people have posted saying that the program is non-conforming. Update: More responses in comp.lang.fortran bring up the point that if trim(line) is supposed to return a temporary, the code might be conforming. Seems that the situation is not clear...
(In reply to comment #3) > (In reply to comment #2) > > Sorry. When I looked after I had posted the question there was only one > > response and that response said it was a bug so I submitted this bug report. > > Now other people have posted saying that the program is non-conforming. > > Update: More responses in comp.lang.fortran bring up the point that if > trim(line) > is supposed to return a temporary, the code might be conforming. Seems that the > situation is not clear... IMNSHO, it's not conforming. trim(line) is associated with line. I don't see how one could interpret the standard in in other way. >
(In reply to comment #4) > (In reply to comment #3) > > (In reply to comment #2) > > > Sorry. When I looked after I had posted the question there was only one > > > response and that response said it was a bug so I submitted this bug report. > > > Now other people have posted saying that the program is non-conforming. > > > > Update: More responses in comp.lang.fortran bring up the point that if > > trim(line) > > is supposed to return a temporary, the code might be conforming. Seems that the > > situation is not clear... > > IMNSHO, it's not conforming. trim(line) is associated with line. > I don't see how one could interpret the standard in in other way. > > > In fact, 16.5.7 in F2003, is fairly unambiguous. The code is nonconforming.
> Update: More responses in comp.lang.fortran bring up the point that if > trim(line) > is supposed to return a temporary, the code might be conforming. Seems that the > situation is not clear... Where in the standard does it say that trim(line) must generate a temporary. I can think of an implementation that would track the length trimmed to and conserve the memory. My point being that this level of behavior, using temporaries or not, IMNSHO, is implementation detail that does not belong in the standard if it is there. c.l.f folks sometimes get a bit esoteric in their discussions. I am closing this bug as not a bug (invalid). I do appreciate the report though. We do not want to miss things and its better to error on the safe side and report then not.