This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about structures,intent(in),pointer elements


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]