What does "void *p = &&abc;" do?

Asked 2 years ago, Updated 2 years ago, 77 views

void *p = &&abc;

I saw a code like this, but I don't know what it's doing.

I've seen a lot of double pointers, but doesn't & mean the address? And you need two operands, so this isn't it.

What does that code do?

gcc c++ c operator

2022-09-22 22:18

1 Answers

&& is one of the gcc extensions used to determine the "address of the label currently in the function". I'll attach an example below

int main(void) {
    void* startp;
s: //Label s
    startp = &&s;
    printf("Address of label s: %p\n", startp);
    return 0;
}

Output: Address of label s: 0x100000f2f


2022-09-22 22:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.