- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
When I use an array constructors for an allocatable array with /assume:realloc_lhs, it changes the bounds of the allocatable array to 1 to size(array):
This produces
Is this a bug, or intended behaviour for /assume:realloc_lhs. I can stop the automatic reallocation by using x(:) in the assignment.
Version:
Cheers,
Ben
When I use an array constructors for an allocatable array with /assume:realloc_lhs, it changes the bounds of the allocatable array to 1 to size(array):
[fortran]program test implicit none integer, dimension(:), allocatable :: x integer :: i allocate(x(-1:22)) write(*, *) lbound(x), ubound(x) x = [ (modulo(i-1, 20) + 1, i = -1, 22) ] write(*, *) lbound(x), ubound(x) end program test[/fortran]
This produces
[plain]L:\>test -1 22 1 24
[/plain]
Is this a bug, or intended behaviour for /assume:realloc_lhs. I can stop the automatic reallocation by using x(:) in the assignment.
Version:
[plain]L:\>ifort Intel Visual Fortran Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.4.196 Build 20110427 Copyright (C) 1985-2011 Intel Corporation. All rights reserved.[/plain]
Cheers,
Ben
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
in the statement x=[(modulo(i-1,20)+1,i=-1,22)]
The rhs is a 1-based array with 24 elements (equivilent to data(1:24))
If you declare y(:) and use
y = x ! (x(-1:22)
The rhs is array of (-1:22) and the lhs receives descriptor as well, resulting in y(-1:22)
However, if you have
y = (x)
The the rhs is the data contained in x(-1:22) without regard to the indexing (iow equivilent1-based data(1:24)
Same issue if you use
y = x(-1:22)
rhs is 1-based reference to data represented by x(-1:22)
The compiler is not broken as far as I know.
Jim Dempsey
The rhs is a 1-based array with 24 elements (equivilent to data(1:24))
If you declare y(:) and use
y = x ! (x(-1:22)
The rhs is array of (-1:22) and the lhs receives descriptor as well, resulting in y(-1:22)
However, if you have
y = (x)
The the rhs is the data contained in x(-1:22) without regard to the indexing (iow equivilent1-based data(1:24)
Same issue if you use
y = x(-1:22)
rhs is 1-based reference to data represented by x(-1:22)
The compiler is not broken as far as I know.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you wish to preserve the indicies check out FOR_DESCRIPTOR_ASSIGN
Jim Dempsey
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, this is a bug. The standard requires reallocation only when the shape of the array changes, and shape is rank and extent (number of elements). The compiler should not be doing the reallocation and bounds change as long as the number of elements match. This will be fixed in Update 6, scheduled for September.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Steve and Jim.
In the meantime, I'll just use x(:) when I don't want reallocation.
Ben
In the meantime, I'll just use x(:) when I don't want reallocation.
Ben

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page