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: allocate() interface (PR30115)


Hi,

Tobias Burnus wrote:
> Thomas Koenig wrote:
>   
>> This is legal, and required to work:
>>
>>     real, pointer :: a(:)
>>     allocate (a(4))
>>     allocate (a(3))
>>
>> and this is illegal:
>>
>>     real, allocatable :: a(:)
>>     allocate (a(4))
>>     allocate (a(3))
>>     
Call me asleep, I of cause missed the fact that the first one is a
pointer and the second one is an array.
What you wrote is of cause correct:
- Allocating an array twice is wrong
- Allocating a pointer twice is ok

For completeness, the reference in the Fortran 2003 standard to the
second point / first example:

"It is not an error to allocate a pointer that is already associated
with a target. In this case, a new pointer target is created as required
by the attributes of the pointer and any array bounds, type, and type
parameters specified by the ALLOCATE statement. The pointer is then
associated with this new target. Any previous association of the pointer
with a target is broken. If the previous target had been created by
allocation, it becomes inaccessible unless other pointers are associated
with it."

Sorry, for wrongly reading what you wrote.

Tobias


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