This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/54597] Function can't return string without trailing spaces
- From: "dongli at lasg dot iap.ac.cn" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 16 Sep 2012 08:52:00 +0000
- Subject: [Bug fortran/54597] Function can't return string without trailing spaces
- Auto-submitted: auto-generated
- References: <bug-54597-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54597
--- Comment #2 from Li Dong <dongli at lasg dot iap.ac.cn> 2012-09-16 08:52:00 UTC ---
(In reply to comment #1)
> (In reply to comment #0)
> > I would like to write a function that will return string without trailing
> > spaces, the prototype of the function is as following:
> >
> > module mod
> >
> > contains
> >
> > function foo()
> >
> > character(*), allocatable :: foo
> > character(1000) bar
> >
> > bar = "abc"
> > foo = bar
> >
> > end function foo
> >
> > end module mod
> >
> > program main
> >
> > use mod
> >
> > write(*, *) """", foo(), """"
> >
> > end program main
> >
> > The result of "gfortran" still contains trailing spaces, but "ifort" works as
> > expected.
>
> Is this the actually code you want to compile?
>
> laptop:kargl[207] gfortran -o z d.f90
> d.f90:5.4:
>
> function foo()
> 1
> Error: Character-valued module procedure 'foo' at (1) must not be\
> assumed length
Yes, it is. I am using gfortran 4.7.1.