The testcase below passes the entry point to 'lll' call as an address of the label ll_def. printf line disappears completely. Obviously people should only use such code when they really know what they are doing. But compilation result here is complately wrong and isn't usable in any way. --- testcase --- #include <stdio.h> #include <stdlib.h> __attribute__ ((noinline)) void lll(void*) { } void mainx() { lll(&&ll_def); return; ll_def: printf("default\n"); return; }
Addresses of labels are only designed to work with computed gotos so if you don't have a computed goto in the function of mainx, then this will not work. See http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Labels-as-Values.html . One thing which is documented is "You may not use this mechanism to jump to code in a different function." It is not about using labels as value extension only when they know what they are doing but rather using them as they are correctly documented as being working. They are only designed for computed gotos. Any other use will cause undefined behavior.
*** Bug 114366 has been marked as a duplicate of this bug. ***
*** Bug 55468 has been marked as a duplicate of this bug. ***
*** Bug 55749 has been marked as a duplicate of this bug. ***
*** Bug 40115 has been marked as a duplicate of this bug. ***
*** Bug 112870 has been marked as a duplicate of this bug. ***
*** Bug 96956 has been marked as a duplicate of this bug. ***
*** Bug 77329 has been marked as a duplicate of this bug. ***
*** Bug 77951 has been marked as a duplicate of this bug. ***
*** Bug 54529 has been marked as a duplicate of this bug. ***
*** Bug 29305 has been marked as a duplicate of this bug. ***
*** Bug 28581 has been marked as a duplicate of this bug. ***
*** Bug 115332 has been marked as a duplicate of this bug. ***