Consider this code snippet:
#include <threads.h>
int thread_start(void *ptr)
{
struct {
int a;
int b;
} *data = ptr;
return 0;
}
int main(int argc, char *argv[])
{
struct {
int a;
int b;
} data;
thrd_t thread;
thrd_create(&thread, thread_start, &data);
thrd_join(thread, NULL);
return 0;
}
Regarding the casting of a void * to struct { int; int } *, assuming that the fields of the anonymous structure are identical to the fields of the structure that was initially allocated, is this well defined behavior according to the C standard?