public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mrestelli at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/63867] New: LEN is lost for a CHARACTER variable inside SELECT TYPE
Date: Fri, 14 Nov 2014 11:42:00 -0000	[thread overview]
Message-ID: <bug-63867-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63867

            Bug ID: 63867
           Summary: LEN is lost for a CHARACTER variable inside SELECT
                    TYPE
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mrestelli at gmail dot com

Consider the following code:

program p
 implicit none

 character(len=5) :: str

 str = 'abcde'
 call checklen1(str)
 call checklen2(str)

contains

 subroutine checklen1(s)
  character(len=*), intent(in) :: s

   call checklen2(s)

 end subroutine checklen1

 subroutine checklen2(s)
  class(*), intent(in) :: s

   select type(s)
    type is(character(len=*))
     write(*,*) "Len is ",len(s)
     write(*,*) "s is   ",s
   end select

 end subroutine checklen2

end program p


When compiled with gfortran it prints

$ ./test
 Len is            0
 s is   
 Len is            5
 s is   abcde

while the expected output is twice the same, i.e.

$ ./test
 Len is            5
 s is   abcde
 Len is            5
 s is   abcde


I.e., inside the SELECT TYPE the lenght of the string is lost, but
only when the actual argument is itself a dummy argument with LEN=* .


 $ gfortran --version
GNU Fortran (GCC) 5.0.0 20141114 (experimental)


Marco


             reply	other threads:[~2014-11-14 11:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-14 11:42 mrestelli at gmail dot com [this message]
2014-11-14 11:48 ` [Bug fortran/63867] " mrestelli at gmail dot com
2014-11-30 11:55 ` dominiq at lps dot ens.fr

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-63867-4@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).