apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@covalent.net>
Subject Re: cvs commit: apr/shmem/unix shm.c
Date Thu, 10 Jan 2002 06:45:17 GMT
From: "Aaron Bannert" <aaron@clove.org>
Sent: Thursday, January 10, 2002 12:31 AM


> >   -        new_m->usable = new_m->base + sizeof(apr_size_t);
> >   +        new_m->usable = (char *)new_m->base + sizeof(apr_size_t);
> 
> What a weird compiler -- it complains about type agreement for addition
> expressions, but not for LHS/RHS agreement on assignment expressions?
> 
> (I suppose it minds adding anything to a void*, but doesn't mind assigning
> a char* to a void*.)

No... that's actually the proper definition.  A void has no size, correct?
So you cannot add the sizeof(* (void*foo)) + x.  By rights, compilers who
assume sizeof(* (void*)) == 1 are actually broken :)

On the other side, void* can be assigned to any * type, while any * type
can be assigned to a void*.  This is really poor practice, but entirely
legal according to spec.  It's the reason void*'s are usually poor choices.


Mime
View raw message