const void* and goto *expr
Dan Hipschman
dsh@linux.ucla.edu
Tue Jun 24 21:16:00 GMT 2008
On Tue, Jun 24, 2008 at 10:13:24PM +0200, Igor Bukanov wrote:
>
> 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;
> }
The && operator yields an object of type "void *", which is what you get
if you print the name with typeid. It should be fine to assign this to
a variable of type "const void *" since "const void *" is a supertype of
"void *".
You are probably correct to say that goto should accept an expression of
type "const void *", since it shouldn't modify the value at the address.
More information about the Gcc-help
mailing list