Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

possible bug with coarray lock_type

$
0
0

I think this is a compiler bug, but I am not 100% confident in my reading of the standard, particularly C1304 in 13.8.2.16.

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

C1304 says:

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 14.0.2.144 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.

AttachmentSize
Downloadintel-lock-bug.f903.11 KB

Viewing all articles
Browse latest Browse all 2746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>