compositeType: void and void*

Benedikt Huber benedikt.huber at
Thu Sep 19 23:03:37 BST 2013

On 02.09.2013, at 22:24, Mikhail Sosonkin wrote:
> Hello,
> This one is slightly more complex. There is a case missing in the
> compositeType function.
>  *** Exception: incompatible types: void *, void
> which can be fixed by the following addition
>  compositeType t1@(PtrType in_t1 q1 a1) t2@(DirectType TyVoid q2 a2)
> = return t1

> Here I'm not sure if I chose the correct type to return. Maybe TyVoid
> would be more appropriate. The case comes up if I pass in (in the C
> input, as attached) a function pointer for a function that returns
> void but the parameter expects it to return a void pointer:
> int pthread_create(pthread_t * ,
>                         const pthread_attr_t * ,
>                         void *(*)(void *),
>                         void * );
> ....
> void modifier(void* arg) {
> ....
> pthread_create(&thread[0], ((void *)0), modifier, ((void *)0));
> I think this is a bug because the C compiler is happy to compile this
> code. I don't think it even gave me a warning.
Hi Mikhail,
the pointer types are incompatible, and both gcc 4.2.1 and clang 3.1
issue a warning because of that.
If I understand correctly, this code will always lead to unspecified
behavior (C99 Therefore it seems plausible to reject the
code, although gcc/clang are more forgiving in this case.
cheers, benedikt

More information about the Language-c mailing list