min/max and string arguments

Daniel Franke franke.daniel@gmail.com
Thu Jan 1 20:44:00 GMT 2009


On Thursday 01 January 2009 21:24:58 Steve Kargl wrote:
> > Let's start this year with a small puzzle :)
> >
> > What should be the proper output of this code fragment?
> >
> > 	print *, MIN ("foo", "", "bar")
> > 	end
> >
> > gfortran answers "bar" while an equivalent C-fragment using strcmp()
> > would result in "".
>
> Looks like a bug.  MIN/MAX state

Shame on me. It isn't. 
Just tried again with a clean tree. All nice and shiny.


> 13.7.76 MIN(...)
>
>     For arguments of character type, the length of the result is the length
>     of the longest argument.
> ....
>     If the selected argument is shorter than the longest argument, the
>     result is extended with blanks on the right to the length of the
>     longest argument.

That's the piece of information  I lacked to understand what's going on!

Steve, thank you very much!

	Daniel



More information about the Fortran mailing list