Behavior of sourced allocation

Behavior of sourced allocation

I know that there are some strict restrictions on what can appear in the source= clause of the allocate statement, but I was surprised when trying to allocate a component of a derived type via sourced allocation where a sibling component (which is allocated and defined) resulted in the following error with ifort 13.0.2.171 Build 20130314: 

statN.F90(352): error #8152: Neither the ERRMSG= variable nor any part of the source expression in SOURCE= or MOLD= specifiers may be allocated in the ALLOCATE statement in which it appears.   [THIS]

	       allocate(this%binkp(1:this%p-2,2:this%p) ,source=temp(1:this%p-2,:))

	---------------------------------------------------------------^

this%p is already defined (it's not even allocatable) and this%binkp is the component I am trying to allocate. Simply replacing this%p by an additional variable (n = this%p) fixes the compile time error. gfortran 4.8.2 has no complaints when compiling the original code FWIW.

Does my statement violate the standard, or is this a bug?

-Zaak
6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I will let Steve or someone familiar with the standards to resolve standard/bug issue.

Try: allocate(this%binkp(1:this%p-2,2:this%p) ,source=temp(1: ( this%p-2 ) ,:))

Jim Dempsey

www.quickthreadprogramming.com

It's a bug. Jim's suggestion doesn't help. I'll report it to the developers. ifort needs to be more careful as to what it is looking at regarding the rules here (F2008. page 127, paragraph 3)  Issue ID is DPD200250346.

Steve - Intel Developer Support

This has been fixed for a major release later this year.

Steve - Intel Developer Support

Thanks Steve.

-Zaak

Since we've now seen two other reports of this problem, the developers have agreed to put the fix into the 14.0 stream. I expect the fix to appear in Update 3.

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today