This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
const void* and goto *expr
- From: "Igor Bukanov" <igor at mir2 dot org>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 24 Jun 2008 22:13:24 +0200
- Subject: const void* and goto *expr
The documentation for GCC states in
http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Labels-as-Values.html#Labels-as-Values
:
You can get the address of a label defined in the current function (or
a containing function) with the unary operator `&&'. The value has
type void *.
Yet apparently, as the following program demonstrates, using const
void* as the type of the label-as-value is fine both with gcc and g++:
~/s $ cat x.c
const void * f()
{
const void *p;
p = &&label;
goto *p;
label:
return p;
}
~/s $ gcc -c -Wall -Wextra x.c
~/s $ g++ -c -Wall -Wextra x.c
~/s $ gcc --version
gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
So what is exactly the type of &&label expression and what goto *expr
accepts as a type of expr?
Regards, Igor