https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88737

--- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> Wouldn't that break e.g. programs that
>   free (a);
>   return (uintptr_t) a % 16;
> or similar (i.e. inspect the bits of the pointer rather than what it points
> to)?
> That should be valid even after free, free doesn't modify the pointer, only
> says that what it points to is no longer available.

Strictly speaking (as described in bug 80532), the value of a pointer becomes
indeterminate after the lifetime of the object it points to ends.  This goes
for all memory: stack as well as the heap.  So the idea of clobbering the
pointer is sound, though it would certainly break code that uses the
indeterminate pointer anyway, such as after realloc.  But I agree that a
warning would be quite helpful here to help find such bad code.

I'm not sure I understand the purpose of the requested attribute or how it
might be used or where.

Reply via email to