- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was playing around with a way to record log messages in an internal "file" (character variable) when I came upon a strange compiler notice. The following module does not compile, producing the error
error #7146: This object must not be used as an allocate-object in an allocate-stmt or deallocate-stmt in a PURE procedure or an internal procedure contained in a PURE procedure. [TEMP]
allocate(temp(2*size(this%buffer)), mold = this%buffer)
Simply removing the associate construct gets rid of the error. Allocation and internal file I/O should both be fine in PURE procedures, right?
module logmod
implicit none
private
type, public :: logger
private
character(128), allocatable :: buffer(:)
integer :: idx = 1
contains
procedure, public, pass(this) :: info
end type logger
contains
pure subroutine info(this, msg)
class(logger), intent(inout) :: this
character(*), intent(in) :: msg
! Temporary buffer
character(:), allocatable :: temp(:)
! This unused association causes error #7146
associate(i => this%idx)
! Check buffer status
if (.not. allocated(this%buffer)) then
! Allocate and fill buffer of initial size 100
allocate(this%buffer(100))
this%buffer = ''
elseif (this%idx == size(this%buffer)) then
! Increase buffer size
allocate(temp(2*size(this%buffer)), mold = this%buffer)
temp(1:size(this%buffer)) = this%buffer
call move_alloc(temp, this%buffer)
endif
write(this%buffer(this%idx), '(a)') msg
this%idx = this%idx + 1
end associate
end subroutine
end module
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Looks like an ifort defect. I'll report this to the developers.
Thanks,
patrick
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Looks like an ifort defect. I'll report this to the developers.
Thanks,
patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Patrick Kennedy (Intel) wrote:
Hello,
Looks like an ifort defect. I'll report this to the developers.
Thanks,
patrick
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This has been reported to the developers. I'll keep this thread update with any news. Tracking #DPD200254361
patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Resolved in Composer XE 2013 SP1 Update 3:
[U507066]$ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.3.174 Build 20140422
Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
[U507066]$ ifort U507066.f90 -c
[U507066]$
Patrick
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page