I think this is a compiler bug, but I am not 100% confident in my reading of the standard, particularly C1304 in 188.8.131.52.
consider the following snippet:
soln = soln%scalar_mul(2.0)
where soln has a coarray lock_type component and the generic assignment resolves to a subroutine 'copy' listed below and scalar_mul() is a function listed below, which returns a non-coarray local object:
subroutine copy(lhs,rhs) class(global_field) ,intent(inout) :: lhs type(local_field) ,intent(in) :: rhs lock(lhs%lock) !just because lhs%field(:) = rhs%field(:) unlock(lhs%lock) call sync_all() end subroutine function scalar_mul(this,nu) result(res) class(global_field) ,intent(inout) :: this real(wp) ,intent(in) :: nu type(local_field) ,allocatable :: res lock(this%lock) !no reason allocate(res) call res%init(this%field*nu) unlock(this%lock) end function
A variable with a subobject of type LOCK TYPE shall not appear in a variable definition context except as an allocate-object or as an actual argument in a reference to a procedure with an explicit interface where the corresponding dummy argument has INTENT (INOUT) .
Since 'this' in the TBP scalar_mul is indeed 'intent(inout)' and 'lhs' in 'copy' is also 'intent(inout)' I don't understand why Intel Fortran compiler 14.x (ifort) is telling me:
$ ifort -Bdynamic -coarray=shared -standard-semantics -O3 -coarray-num-images=2 -c intel-lock-bug.f90 intel-lock-bug.f90(102): error #8479: A lock variable or a variable with a subobject of type LOCK TYPE shall not appear in this definition context. [SOLN] soln = soln%scalar_mul(2.0_wp) --^ compilation aborted for intel-lock-bug.f90 (code 1) $ ifort -V Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 184.108.40.206 Build 20140120 Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
I’m pretty sure this is a compiler error, unless I’m missing something in the standard.