This is a compound literal, with a constraint violation since initializer braces cannot be empty:
(pthread_t[]){}
Using gcc -std=c99 -Wall -Wextra -Wpedantic
this produces the warning:
compound_literal_pthread.c:6:36: warning: ISO C forbids empty initializer braces [-Wpedantic]
pthread_t *ptr = (pthread_t []){};
The result seems to be a pointer to pthread_t
, though I don't see this behavior documented in the gcc manual. Note that empty braces are allowed as initializers in C++, where they are equivalent to { 0 }
. This behavior seems to be supported for C, but undocumented, by gcc. I suspect that is what is happening here, making the above expression equivalent to:
(pthread_t[]){ 0 }
On my system, pthread_t
is a typedef
for unsigned long
, so this expression would create an array of pthread_t
containing only a 0
element. This array would decay to a pointer to pthread_t
in the function call.