DEALLOCATE Of Non-ALLOCATEd Should Be No-Op

Liste des GroupesRevenir à cl fortran 
Sujet : DEALLOCATE Of Non-ALLOCATEd Should Be No-Op
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.fortran
Date : 17. Oct 2024, 01:51:26
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vepn2d$2f9jq$1@dont-email.me>
User-Agent : Pan/0.160 (Toresk; )
It’s annoying to find that if you try to DEALLOCATE an ALLOCATABLE
variable that has not been ALLOCATEd (or that has already been
DEALLOCATEd), this is an error.

The usual practice is for storage-disposal calls to be harmless no-ops if
called with a NULL pointer (or equivalent). This is true of the C/POSIX
free(3) call <https://manpages.debian.org/3/free.3.en.html>, for example,
and also for the “delete” statement in C++.

This way, one can simplify cleanup by 1) ensuring all temporary pointers
are initialized to NULL at the start, and 2) unconditionally freeing all
of them at the end.

I suppose Fortran tries to simplify things by handling both conventions
automatically, but this still causes irritations in other places, like
loops.

Date Sujet#  Auteur
17 Oct 24 * DEALLOCATE Of Non-ALLOCATEd Should Be No-Op5Lawrence D'Oliveiro
17 Oct 24 `* Re: DEALLOCATE Of Non-ALLOCATEd Should Be No-Op4Gary Scott
17 Oct 24  `* Re: DEALLOCATE Of Non-ALLOCATEd Should Be No-Op3Lawrence D'Oliveiro
17 Oct 24   `* Re: DEALLOCATE Of Non-ALLOCATEd Should Be No-Op2R Daneel Olivaw
17 Oct 24    `- Re: DEALLOCATE Of Non-ALLOCATEd Should Be No-Op1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal