- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it possible for the DEALLOCATE statement to error if you don't violate any rules for the statement and the array was allocated?
If you don't do something stupid like trying to deallocate an array that was never allocated, trying to deallocate a global array that is being used in another thread (maybe), or something silly like DEALLOCATE(Status,STAT=Status(1)), what could cause it to fail?
We are trying to make our software so that it never aborts in a subroutine, but sets error flags and reverses the call stack to the main program for it to abort. We were trying to figure what could possibly cause the deallocation to fail that could be a run-time error not associated with bad programming. Other than debugging you code, is there any real reason to check the error status of a DEALLOCATE?
I'm talking about arrays and not pointers.
Marshall
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have experienced this kind of behavior when I get a buffer overlow somewhere else in my code.
Trying to access an element outside an existing array (f.e. because the size was underestimated) may result in this problem when deallocating another array.
Best regards,
Phil.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But, isn't that a programming error and not user or OS error?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Should "arrays and not pointers" at the end of the original post be "allocatables and not pointers"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would agree that an error from DEALLOCATE is almost always due to a programming error in the application. The two typical causes of such errors are 1) Variable is already deallocated and 2) something has corrupted the data used to keep track of allocated variables. An OS error would be extremely unlikely.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page