This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: const void* and goto *expr
- From: Dan Hipschman <dsh at linux dot ucla dot edu>
- To: Igor Bukanov <igor at mir2 dot org>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 24 Jun 2008 14:16:22 -0700
- Subject: Re: const void* and goto *expr
- References: <7dee4710806241313w787534dcgc6279f2f3de60698@mail.gmail.com>
- Reply-to: dsh at linux dot ucla dot edu
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.