I saw a program in C that had code like the following:
static void *arr[1] = {&& varOne,&& varTwo,&& varThree};
varOne: printf("One") ;
varTwo: printf("Two") ;
varThree: printf("Three") ;
I am confused about what the && does because there is nothing to the left of it. Does it evaluate as null by default? Or is this a special case?
Edit: Added some more information to make the question/code more clear for my question. Thank you all for the help. This was a case of the gcc specific extension.
It's a gcc-specific extension, a unary
&&operator that can be applied to a label name, yielding its address as avoid*value.As part of the extension,
goto *ptr;is allowed whereptris an expression of typevoid*.It's documented here in the gcc manual.
As zwol points out in a comment, gcc uses
&&rather than the more obvious&because a label and an object with the same name can be visible simultaneously, making&foopotentially ambiguous if&means "address of label". Label names occupy their own namespace (not in the C++ sense), and can appear only in specific contexts: defined by a labeled-statement, as the target of agotostatement, or, for gcc, as the operand of unary&&.