This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: DR#236 analysis


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]