From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32681 invoked by alias); 18 Aug 2010 07:26:29 -0000 Received: (qmail 32653 invoked by uid 22791); 18 Aug 2010 07:26:27 -0000 X-SWARE-Spam-Status: No, hits=-0.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-bw0-f47.google.com (HELO mail-bw0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 18 Aug 2010 07:26:22 +0000 Received: by bwz12 with SMTP id 12so339706bwz.20 for ; Wed, 18 Aug 2010 00:26:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.102.68 with SMTP id f4mr5247071bko.30.1282116379637; Wed, 18 Aug 2010 00:26:19 -0700 (PDT) Received: by 10.204.143.154 with HTTP; Wed, 18 Aug 2010 00:26:19 -0700 (PDT) In-Reply-To: <4C6B135B.4080303@net-b.de> References: <4C6A3E58.40102@net-b.de> <4C6AF2D5.9020600@net-b.de> <4C6B135B.4080303@net-b.de> Date: Wed, 18 Aug 2010 07:44:00 -0000 Message-ID: Subject: Re: [Patch, Fortran, F08] PR45290: pointer initialization From: Janus Weil To: Tobias Burnus Cc: gfortran , gcc-patches Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-08/txt/msg01330.txt.bz2 > That looks perfectly valid, cf. below. > > - =A0 =A0integer(c_int), dimension(:), pointer :: int_ptr > - =A0 =A0my_c_ptr =3D c_loc(int_ptr(0)) > > > Well, as written is is invalid - but change it to > > - =A0 =A0integer(c_int), dimension(:), pointer :: int_ptr > ALLOCATE(int_ptr(0:10)) > - =A0 =A0my_c_ptr =3D c_loc(int_ptr(0)) > > > Then it is valid. ... which means that a through check for validity is very hard to do at compile time, since it depends on the run-time value, right? > Note: "int_ptr(0)" is not a pointer but "int_ptr(0)" is > the first element of the array to which int_ptr points. That array is > unnamed but has the TARGET attribute. If you want to have a named target, > use: > > integer, target :: tg(0:10) > - =A0 =A0integer(c_int), dimension(:), pointer :: int_ptr > int_ptr =3D> =A0tg > - =A0 =A0my_c_ptr =3D c_loc(int_ptr(0)) > > In this case int_ptr(0) is the first element of "tg" and "tg" has the TAR= GET > attribute. Well, ok. I guess that is one way to look at it. However, if I apply the same logic to your earlier pointer-init example ... module m integer, target, save :: t1 integer, pointer :: p1 =3D> t1 integer, pointer :: p3 =3D> p1 end module m ... then I'd say this is valid, too. p1 itself is a pointer, but the thing that it points to is a target (namely t1). Therefore "p3 =3D> p1" is valid, since the object on the RHS has the TARGET attribute. Can we agree on that? Cheers, Janus