Bonjour,
La FAQ dans sa question Que vaut un pointeur après free() ?
énonce :
Je pense que cette assertion est inexacte. Voici les passages de la Norme sur lesquels je m'appuie pour dire cela :Le pointeur reste inchangé (en effet il est passé par valeur à free)
7.20.3 Memory management functions
1 (...) The lifetime of an allocated object extends from the allocation until the deallocation.Cordialement6.2.4 Storage durations of objects
1 2 An object has a storage duration that determines its lifetime. There are three storage durations: static, automatic, and allocated. Allocated storage is described in 7.20.3.
(...)
The value of a pointer becomes indeterminate when the object it points to reaches the end of its lifetime.
Partager