Can anything but a programming bug cause a deallocation error?

Can anything but a programming bug cause a deallocation error?

Imagen de marshall-l-buhl

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

publicaciones de 5 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de netphilou31

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.

Imagen de marshall-l-buhl

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

Imagen de IanH

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

Imagen de 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.

Steve

Inicie sesión para dejar un comentario.