This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: const void* and goto *expr


Hi Ho!

--- On Wed, 6/25/08, "Igor Bukanov" <igor@mir2.org> wrote:

> But this is what GCC does already as the example demonstrates: it
> accepts const void* as the type of exp in "goto *exp" in addition to
> plain void*. This is both with gcc and g++. The question is this
> intended behavior? If the answer is yes, then the documentation has a
> bug. If the answer is no, then this is a bug in GCC.

Yes, it is intended. But, neither the doc nor GCC has a bug.
Why? Because the goto operator can be considered as the following function:
void goto(const void *ptr);

Since `const void *ptr' is a superset of `void *ptr' as Dan mentioned, goto can accept `void *ptr' too.

As another illustration, a function like:
int strcmp(const char *a, const char *b);

should accept non-constant pointers to character as its arguments, shouldn't it?

> The issue came up when compiling with the Intel compiler a code with
> computed code that used const void*. GCC was dealing with that code
> just fine but icc insisted that the type should be void*. I guess
> Intel folks just followed documentation when implemented the
> computed-goto in their compiler.

I guess Intel folks walked the wrong path of not knowing that `const void *' is the superset of `void *'.

> Regards, Igor

Best regards,
Eus


      


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]