public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/53296] Segfault on non-constant character array constructor containing kind spec
Date: Thu, 10 May 2012 11:29:00 -0000	[thread overview]
Message-ID: <bug-53296-4-8LFDE1Drqo@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53296-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-10 10:35:22 UTC ---
Simplified program.

* As is, it prints 128
* Without  "txt", it prints 5 and segfaults
* Without  character(len=128) :: "txt",   it prints 5 and works

Thus, the extension to 128 characters does not properly work in the case of
having no character literal. That matches what is in the code:

          character(kind=1) A.16[2][1:5];
vs.
          character(kind=1) A.15[3][1:128];


I have not looked through the source code, but the first place, where
constructors string lengths are handled is array.c's
gfc_resolve_character_array_constructor. I don't quickly see whether it does so
correctly or not. If it does, the failure must be later.

It might be that in that function, the "txt" is correctly extended and padded
to len=128 - and that then everything is later handled correctly because the
first element has the right size?


program charArrErr
  implicit none
  call rou([character(len=128) :: "txt", uCase("abcde"),uCase("ghij_")])
contains
  subroutine rou(arr)
    implicit none
    character(*),intent(in) :: arr(:)
    print *, len(arr)
  end subroutine

  function uCase(str)
    implicit none
    character(*), intent(in) :: str
    character(len(str)) :: uCase
    uCase=str
  end function uCase
end program charArrErr


      parent reply	other threads:[~2012-05-10 10:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-09 15:53 [Bug fortran/53296] New: " gccbgz.lionm at xoxy dot net
2012-05-09 17:24 ` [Bug fortran/53296] " burnus at gcc dot gnu.org
2012-05-10 11:29 ` burnus at gcc dot gnu.org [this message]

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-53296-4-8LFDE1Drqo@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).