public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Richard Thomas <paul.richard.thomas@gmail.com>
To: "Dominique d'Humières" <dominiq@lps.ens.fr>
Cc: Steve Kargl <sgk@troutmask.apl.washington.edu>,
		"fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
	Damian Rouson <damian@sourceryinstitute.org>,
		Louis Krupp <louis.krupp@zoho.com>
Subject: Re: Ping: [Patch, fortran] Bug 68241 - [meta-bug] Deferred-length character - PRs50221, 68216, 63932, 66408, 67674 and 49954
Date: Sun, 15 Nov 2015 08:21:00 -0000	[thread overview]
Message-ID: <CAGkQGiJ7BHe3pF2z3OQR14V5BFddnieQ3aRbx1vL7Df31JQKEw@mail.gmail.com> (raw)
In-Reply-To: <2EC098E0-3995-442D-8A9B-84553E97ECC1@lps.ens.fr>

Dear Dominique et al.,

This problem I can reproduce :-) I can even see what the problem is,
although I can do nothing about it for an hour or so because I have
updated trunk, ready for the commit, and am rebuilding/regtesting.

print '(">",a,"<")', strings(1:5) produces:

  {
    struct __st_parameter_dt dt_parm.0;

    dt_parm.0.common.filename = &"deferred_character_4.f90"[1]{lb: 1 sz: 1};
    dt_parm.0.common.line = 34;
    dt_parm.0.format = &"(\">\",a4,\"<\")"[1]{lb: 1 sz: 1};
    dt_parm.0.format_len = 12;
    dt_parm.0.common.flags = 4096;
    dt_parm.0.common.unit = 6;
    _gfortran_st_write (&dt_parm.0);
    {
      struct array1_unknown parm.1;

      parm.1.dtype = ((integer(kind=8)) SAVE_EXPR <(sizetype)
NON_LVALUE_EXPR <.strings>> << 6) + 49;
      parm.1.dim[0].lbound = 1;
      parm.1.dim[0].ubound = 5;
      parm.1.dim[0].stride = 1;
      parm.1.data = (void *) &(*(character(kind=1)[0:][1:.strings] *
restrict) strings.data)[1 - strings.dim[0].lbound];
      parm.1.offset = 0;
      _gfortran_transfer_array_write (&dt_parm.0, &parm.1, 1, .strings);
    }
    _gfortran_st_write_done (&dt_parm.0);
  }

This is fine, except for the data pointer offset for 'parm.1', where a
normal array reference is used. This happens in
trans-array.c(gfc_get_dataptr_offset). Line 6403,   tmp =
build_array_ref (desc, offset, NULL, NULL); which does not use the
opportunity to pass the backend_decl for 'strings', thereby triggering
the use of pointer arithmetic for the offset.

This has not changed between the versions of the patch, so it is
something of a miracle that it ever worked.

I will check this diagnosis before committing and will put it right,
accordingly. I will also update the testcase to include an array
section.

Cheers

Paul

On 14 November 2015 at 19:55, Dominique d'Humières <dominiq@lps.ens.fr> wrote:
> Dear Paul,
>
> Update with your latest patch. Using the following patch
>
> --- /opt/gcc/work/gcc/testsuite/gfortran.dg/deferred_character_4.f90    2015-11-14 19:28:59.000000000 +0100
> +++ deferred_character_4_db.f90 2015-11-14 19:43:55.000000000 +0100
> @@ -21,6 +21,16 @@ program chk_alloc_string
>
>      strings = [character(len=4) :: "A", "C", "ABCDE", "V", "zzzz"]
>
> +    print *, len(strings), size(strings, 1)
> +    do i = 1, size(strings, 1)
> +      print *, "'",strings(i),"'"
> +    end do
> +    print *, "other print"
> +    print *, (strings(i), i= 1, size(strings, 1))
> +    print *, "'", strings(1),"' '", strings(2), "' '", strings(3), "' '", strings(4), "' '", strings(5), "'"
> +    print *, "'", strings, "'"
> +    print '(">",a,"<")', strings
> +    print '(">",a,"<")', strings(1:5)
>      if (len(strings) .ne. 4) call abort
>      if (size(strings, 1) .ne. 5) call abort
>      if (any (strings .ne. [character(len=4) :: "A", "C", "ABCD", "V", "zzzz"])) call abort
>
> the output is now correct except the one for print '(">",a,"<")', strings(1:5) which is now
>
>>A   <
>>A   <
>>A   <
>>A   <
>>A   <
>
> It was correct with the previous patch.
>
> Everything else looks good.
>
> IMO the latest issue may be delayed after a commit!-)
>
> Dominique
>
>> Le 14 nov. 2015 à 19:25, Paul Richard Thomas <paul.richard.thomas@gmail.com> a écrit :
>>
>> Hi Steve,
>>
>> Following an email from Dominique to me, I think not. In the course of
>> fixing PR49954, I put right the setting of the descriptor dtype. Since
>> this gets passed to the IO runtime, I think that this is the reason
>> for the difference in behaviour.
>>
>> I think that another week of effort should put right gfortran's woes
>> with deferred characters. As well as concatenation problems that I
>> think I have fixed, parentheses cause instant death :-(
>>
>> Cheers
>>
>> Paul



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx

  reply	other threads:[~2015-11-15  8:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-14 17:39 Paul Richard Thomas
2015-11-14 17:49 ` Steve Kargl
2015-11-14 18:25   ` Paul Richard Thomas
2015-11-14 18:55     ` Dominique d'Humières
2015-11-15  8:21       ` Paul Richard Thomas [this message]
2015-11-14 20:10     ` Steve Kargl
2015-11-15 14:13       ` Paul Richard Thomas
2015-12-18 18:12         ` Paul Richard Thomas
2015-12-18 18:39           ` Steve Kargl
2015-12-18 18:58             ` Paul Richard Thomas
2015-12-19 11:29               ` Paul Richard Thomas
2016-01-08 23:09           ` Paul Richard Thomas

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=CAGkQGiJ7BHe3pF2z3OQR14V5BFddnieQ3aRbx1vL7Df31JQKEw@mail.gmail.com \
    --to=paul.richard.thomas@gmail.com \
    --cc=damian@sourceryinstitute.org \
    --cc=dominiq@lps.ens.fr \
    --cc=fortran@gcc.gnu.org \
    --cc=louis.krupp@zoho.com \
    --cc=sgk@troutmask.apl.washington.edu \
    /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).