tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: why cast to char* through void*



On Thu, Jul 02, 2009 at 07:48:50PM -0400, Greg A. Woods wrote:
> At Thu, 2 Jul 2009 14:59:39 -0400, christos%zoulas.com@localhost (Christos 
> Zoulas) wrote:
> > I agree, and lint should be fixed instead of polluting the code with linted
> > comments.
> 
> I don't think lint can, or needs to be, fixed in this case though.
> 
> I.e. the lint warning is valid in most cases -- this isn't necessarily a
> safe construct.

I think more often than not, a cast to (char *) in the modern era where
we have (void *) as a generic pointer is in fact likely to be intentional
and safe -- it indicates the programmer really, *really* wanted bytewise
access to the structure in question.

I think this is almost certainly why the pointer-aliasing rules, in fact,
make a special exception for (char *), and so I think lint should, too.

Thor


Home | Main Index | Thread Index | Old Index