- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When I use block and derived data type at same time, some errors occurred.
This is the code, the correct code is
module Test implicit none type :: s integer,allocatable,dimension(:)::x end type s end module Test program main use Test implicit none type(s),allocatable::a(:) type(s)::b integer::i i=2 if (i == 1) then block !allocate (a(3)) end block else block allocate (a(5)) do i = 1, 5 a(i)%x=[i] end do b = a(2) write (*, *) end block end if end program main
and we get that the b%x is a array with size 1, and value is 2. As the figure show
But if we uncomment the allocate (a(3)) statement, we get
the b%x is Undefined address, but the allocate (a(3)) statement should not run , and doesn't affect the result of b. So I dont't know if it's a bug of ifort.
- Tags:
- Bug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it's a bug. With the first allocate commented out, the compiler is deallocating array a at the end of the second block, which it should do only if it was declared within that block (it wasn't). With the first allocate uncommented, the compiler doesn't do the bad deallocate.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it's a bug. With the first allocate commented out, the compiler is deallocating array a at the end of the second block, which it should do only if it was declared within that block (it wasn't). With the first allocate uncommented, the compiler doesn't do the bad deallocate.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page