This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Question about structures,intent(in),pointer elements
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Rimvydas Jasinskas <rimvydasjas at gmail dot com>
- Cc: fortran at gcc dot gnu dot org
- Date: Sat, 1 Feb 2014 06:08:42 -0800
- Subject: Re: Question about structures,intent(in),pointer elements
- Authentication-results: sourceware.org; auth=none
- References: <CAFmAMQ2cq8Mj6xum5WR4aaNXYQ98yo=vMQtHQidO3+uuhpXdog at mail dot gmail dot com>
On Sat, Feb 01, 2014 at 01:17:44PM +0200, Rimvydas Jasinskas wrote:
> Hello everyone,
>
> I am dealing with huge dinamic nested structures,
> while refactoring code I came up with some issues.
>
> gcc version 4.8.2 20131219 (prerelease) (GCC) on ARCH
>
> There is an example:
>
> $ cat test_intent.f90
> subroutine foo(bar1,bar2,bar3,bar4)
> implicit none
> type type1
> logical,pointer :: ll
> endtype type1
> logical ,intent(in) :: bar1
> logical,allocatable,intent(in) :: bar2
> logical,pointer ,intent(in) :: bar3
> type(type1) ,intent(in) :: bar4
>
> bar1=.false.
> bar2=.false.
> bar3=.false.
> bar4%ll=.false.
> endsubroutine foo
>
> $ gfortran -c -Wall -Wextra test_intent.f90 -std=f2003
>
> I quite familiar with f95 std and I would naturally expect to have 4 errors:
> Error: Dummy argument 'barX' with INTENT(IN) in variable definition
> context (assignment)
Understanding the lack of error with bar3=.false. may
be related to the fact that you are not actually changing
bar3. You're changing the target associated with bar3.
Add
logical, target :: foo3 = .true.
bar3=>foo3
to your test.
For the bar4 case, I need to re-read the standard, but
I'm running out the door shortly.
--
Steve