Liste des Groupes | Revenir à cl c |
On 2025-01-10, Michael S <already5chosen@yahoo.com> wrote:...On Thu, 09 Jan 2025 23:40:52 -0800
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
int *ptr = malloc(sizeof *ptr);>
*ptr = 42;
printf("*ptr = %d\n", *ptr);
free(ptr);
>
After the call to free(), the int object logically no longer exists.
Also, the value of the pointer object ptr becomes indeterminate.
Attempting to refer to the value of either ptr or *ptr has undefined
behavior.
>
I believe that the Standard really says that, but find the part about
value of ptr variable ridiculous. It breaks natural hierarchy by which
standard library is somewhat special, but it is not above rules of core
language.
The library is above the rules because it is not required to be
written in strictly conforming ISO C.
Les messages affichés proviennent d'usenet.