public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mikael at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/35612] testsuite ISO_C_BIND code error
Date: Tue, 06 Jan 2009 21:16:00 -0000	[thread overview]
Message-ID: <20090106211631.4820.qmail@sourceware.org> (raw)
In-Reply-To: <bug-35612-13225@http.gcc.gnu.org/bugzilla/>



------- Comment #4 from mikael at gcc dot gnu dot org  2009-01-06 21:16 -------
(In reply to comment #2)
> > The line:
> >   TYPE(C_PTR), INTENT(IN) :: CPTR ! The C address
> > should be:C_F_STRING(CPTR)
> >   TYPE(C_PTR), VALUE, TARGET:: CPTR ! the C address
> 
> You are right. The call to strlen is OK in either case, however, the call to
> C_F_POINTER() does not make sense for a pointer to a C string ("**char") only
> for the version with VALUE ("*char") as fptr should finally contain the string.
> 

For TARGET, I agree because the standard says about c_f_pointer:
   The value of CPTR shall not be the C address of a Fortran variable that does
   not have the TARGET attribute.

However, for VALUE, I fail to understand what is wrong.
Without value, the code generated is:
c_f_string (struct array1_unknown & __result, integer(kind=4) .__result, void *
& cptr)
{
    (...)
    (*(integer(kind=4)[1] *) atmp.0.data)[0] = strlen (*cptr);
    (...)
    c_f_pointer_s0 (*cptr, (struct array1_unknown *) __result, &atmp.3, 1);
}

With value:
c_f_string (struct array1_unknown & __result, integer(kind=4) .__result, void *
cptr)
{
    (...)
    (*(integer(kind=4)[1] *) atmp.0.data)[0] = strlen (cptr);
    (...)
    c_f_pointer_s0 (cptr, (struct array1_unknown *) __result, &atmp.3, 1);
}

Both seem equally good, aren't they?


-- 


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


  parent reply	other threads:[~2009-01-06 21:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17  3:49 [Bug fortran/35612] New: " danp57 at optonline dot net
2008-03-17 16:01 ` [Bug fortran/35612] " toon at moene dot indiv dot nluug dot nl
2008-03-17 23:38 ` burnus at gcc dot gnu dot org
2008-03-18  1:23 ` danp57 at optonline dot net
2009-01-06 21:16 ` mikael at gcc dot gnu dot org [this message]
2009-01-07 13:52 ` mikael at gcc dot gnu dot org
2010-05-02 14:00 ` dfranke at gcc dot gnu dot org
     [not found] <bug-35612-4@http.gcc.gnu.org/bugzilla/>
2010-12-27 23:28 ` dfranke at gcc dot gnu.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=20090106211631.4820.qmail@sourceware.org \
    --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).