compositeType: void and void*

Mikhail Sosonkin mike at nanotick.net
Mon Sep 2 21:24:33 BST 2013


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.

Thanks,
Mike.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: multi.E
Type: application/octet-stream
Size: 14924 bytes
Desc: not available
URL: <http://projects.haskell.org/pipermail/language-c/attachments/20130902/3954cd11/attachment.obj>


More information about the Language-c mailing list