public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/37926]  New: Program gives wrong output (connected to char len)
@ 2008-10-27 10:17 janus at gcc dot gnu dot org
  2008-10-27 22:20 ` [Bug fortran/37926] " burnus at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: janus at gcc dot gnu dot org @ 2008-10-27 10:17 UTC (permalink / raw)
  To: gcc-bugs

Consider the following code:


module m

contains

  pure integer function mysize(a)
    integer,intent(in) :: a(:)
    mysize = size(a)
  end function

end module


program prog

use m
implicit none

character(3) :: str

integer :: i(3) = (/1,2,3/)

str = p(i,mysize)

print *,str,len(str)

contains

  function p(y,asz)
    implicit none
    integer :: y(:)
    interface
      pure integer function asz(c)
        integer,intent(in) :: c(:)
      end function
    end interface
    character(asz(y)) p
    integer i
    do i=1,asz(y)
      print *,y(i),achar(iachar('A')+y(i))
      p(i:i) = achar(iachar('A')+y(i))
    end do
    print *,p,len(p)
  end function

end


Compiling this with GCC trunk rev. 141361 does work, but when running the
produced binary the output is:

           1 B
           2 C
           3 D
 BCD           3
 B             3

The first four lines are ok, but the last one should actually be equal to the
second to last one.

The program does give the expected ouput when the implementation of mysize is
changed such that it always returns a constant (e.g. "3").

Compiling with 4.3.1 gives an ICE.
Compiling with g95 works and gives the right output.


-- 
           Summary: Program gives wrong output (connected to char len)
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37926


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-11-24 19:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-27 10:17 [Bug fortran/37926] New: Program gives wrong output (connected to char len) janus at gcc dot gnu dot org
2008-10-27 22:20 ` [Bug fortran/37926] " burnus at gcc dot gnu dot org
2008-10-28 18:44 ` pault at gcc dot gnu dot org
2008-11-08 17:52 ` pault at gcc dot gnu dot org
2008-11-14 19:02 ` pault at gcc dot gnu dot org
2008-11-15  5:58 ` pault at gcc dot gnu dot org
2008-11-15 17:29 ` pault at gcc dot gnu dot org
2008-11-16 12:03 ` pault at gcc dot gnu dot org
2008-11-24 19:21 ` pault at gcc dot gnu dot org
2008-11-24 19:22 ` pault at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).