public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "janus at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/37926]  New: Program gives wrong output (connected to char len)
Date: Mon, 27 Oct 2008 10:17:00 -0000	[thread overview]
Message-ID: <bug-37926-16146@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2008-10-27 10:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-27 10:17 janus at gcc dot gnu dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-37926-16146@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).