Subject: Re: Intermediate void* casts
To: None <tech-misc@NetBSD.ORG>
From: Ben Harris <bjh21@netbsd.org>
List: tech-misc
Date: 08/11/2003 12:05:53
In article <m2n.s.19ltBX-000prh@chiark.greenend.org.uk> you write:
>Since we will switch to gcc3.3.1 soon and already had first problems
>with incorrect code due to alias bugs, I think we should have a kind
>of a mini audit for these. Usually gcc 3.3.1 warns about this kind
>of problems, but it shuts up if an intermediate void* cast is involved.
>So I tried to find dubious casts to pointer types after casts to void*.
>
>I found quite a few of them, which was a bit of a suprise to me.
I think they're reasonably common because casting through void * is a way of
telling lint, "I know what I'm doing," usually in the area of pointer
alignment.
> - The (void*) cast can just be removed.
> A real world example: char *p; some_func((void**)(void*)&p);
This looks much like the kind of thing suggested twice by
<http://www.netbsd.org/developers/lint/>. You might like to update that
document to suggest passifying lint some other way.
--
Ben Harris