Can anything but a programming bug cause a deallocation error?

Can anything but a programming bug cause a deallocation error?

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.


5 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Ritratto di netphilou31


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,


But, isn't that a programming error and not user or OS error?

Should "arrays and not pointers" at the end of the original post be "allocatables and not pointers"?

Ritratto di Steve Lionel (Intel)

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.


Accedere per lasciare un commento.