public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andre Vehreschild <vehre@gmx.de>
To: Mikael Morin <mikael.morin@sfr.fr>
Cc: Steve Kargl <sgk@troutmask.apl.washington.edu>,
	GCC-Patches-ML <gcc-patches@gcc.gnu.org>,
	GCC-Fortran-ML <fortran@gcc.gnu.org>,
	Paul Richard Thomas <paul.richard.thomas@gmail.com>
Subject: Re: [RFC, Fortran, (pr66775)] Allocatable function result
Date: Sat, 11 Jul 2015 10:58:00 -0000	[thread overview]
Message-ID: <20150711125835.4179a657@vepi2> (raw)
In-Reply-To: <55A0F5E9.2070705@sfr.fr>

Hi,

> > module foo
> >    contains
> >    function bar(i)
> >       integer, allocatable :: bar
> >       integer, intent(in) :: i
> >       if (i > 0) bar = i
> >    end function bar
> > end module foo
> > 
> > program test
> >    use foo
> >    integer j
> >    j = bar( 3); print *, j
> >    j = bar(-3); print *, j
> >    end if
> > end program test
> > 
> > Even if Andre developed a patch to allocate memory in
> > bar() for the i <= 0 case to prevent the segfault, the
> > function must return a value.  What should that value be?
> Your example is, of course, 100% invalid; a value is needed to put in j.
> But the case is more debatable to me, if j is allocatable.
> In that case an unallocated bar() result could just make j unallocated.

Yes, completely right. The example so far is not on the point I try to make.
For your example Steve, the result of bar has to be allocated, no argument on
that, but what about, when j is allocatable? As stated in a previous mail,
that property is not called allocated, but allocatable...

- Andre
-- 
Andre Vehreschild * Email: vehre ad gmx dot de 

  reply	other threads:[~2015-07-11 10:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-09 10:25 Andre Vehreschild
2015-07-09 17:50 ` Steve Kargl
2015-07-09 18:59   ` Andre Vehreschild
2015-07-09 19:41     ` Steve Kargl
2015-07-10  9:44       ` Andre Vehreschild
2015-07-10 13:41         ` Steve Kargl
2015-07-10 16:20           ` Mikael Morin
2015-07-10 16:44             ` Andre Vehreschild
2015-07-10 18:57             ` Steve Kargl
2015-07-11 10:37               ` Andre Vehreschild
2015-07-11 11:06                 ` Mikael Morin
2015-07-11 11:58                 ` Dan Nagle
2015-07-13 17:27                   ` Mike Stump
2015-07-11 10:54               ` Mikael Morin
2015-07-11 10:58                 ` Andre Vehreschild [this message]
2015-07-11 15:37                 ` Steve Kargl

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=20150711125835.4179a657@vepi2 \
    --to=vehre@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mikael.morin@sfr.fr \
    --cc=paul.richard.thomas@gmail.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).