I've been running Splint on a body of code which creates a synonym of
void through a typedef in order to implement an overloaded data type:

typedef void foo;

typedef struct type1 {
    int a;
} typeone;

typedef struct type2 {
    float e;
} typetwo;

void handler (foo *);

int main (int argc, char *argv[])
{
    typeone a;
    handler(&a);
    return 0;
}

When I run Splint on this code, I get the warning, "Function handler
expects arg 1 to be foo * gets typeone *: &a".  If I change the typedef to

   typedef void * foop;

and then change the prototype of handler to

   void handler (foop);

then Splint is fine with it.  I can also use "#define foo void" and
then declare handler as taking (foo *); Splint doesn't object to that,
either.

This is a very widely-used idiom in the code I'm analyzing; switching
to the "foop" form would require a lot of fairly arbitrary code
changes.  Is this a bug in Splint, or is this code just depending on
semantics which are looser than ANSI/ISO C gives us?

Thanks for any advice.

Keith D. Browne
Programmer, Legato Systems Canada Inc.
[EMAIL PROTECTED]

Reply via email to