DR#236 analysis
Ian Lance Taylor
ian@wasabisystems.com
Fri Dec 3 22:58:00 GMT 2004
Geoff Keating <geoffk@geoffk.org> writes:
> I see. Yes, that's not what I meant. In this case, the type of the
> malloc-ed memory is 'struct elf_link_hash_entry', and that's what's
> not allowed to change; what I want prohibited is code like:
>
> void * mem = malloc (max (sizeof (int), sizeof (float));
> *(int *)mem = 1;
> *(float *)mem = 2.0;
>
> where the top-level type of the memory changes.
I see. That does seem uncommon. One case where this happens is in
the malloc implementation itself, in which a freed pointer is treated
as a pointer to some free list structure. But I suppose that case
would be OK, since after the call to free the programmer isn't
permitted to dereference the original pointer anyhow.
Hmmm, do we have to worry about user-level memory managers, like
obstacks?
Ian
More information about the Gcc
mailing list