Re: Optimization bug in VC++ 6.0

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Alexander Grigoriev (alegr_at_earthlink.net)
Date: 03/24/04


Date: Tue, 23 Mar 2004 20:06:16 -0800

This code is not valid C.

Conversion of function pointer to void* is not allowed by C standard. See
ANSI C, paragraph 6.3.2.3.

Use exact function pointer type in your table. It will save you from errors.
Practice type-safe programming. The less casts, the better.

"Emmanuel Stapf" <manus_remove@remove_this_too.eiffel.com> wrote in message
news:epztw9JEEHA.4080@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> The following code fails to compile and cl (VC++ 6.0 SP5) returns an
internal
> error.
>
> extern void f();
>
> void *tab[40];
> void tab_init () {
> long i;
> for (i = 8; i < 11; i++) {
> tab[i] = (void *) f;
> }
> }
>
> command line used: cl -Ox -c a.c
>
> compiler output:
> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for
80x86
> Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
>
> a.c(7) : fatal error C1001: INTERNAL COMPILER ERROR
> (compiler file 'E:\8966\vc98\p2\src\P2\main.c', line 494)
> Please choose the Technical Support command on the Visual C++
> Help menu, or open the Technical Support help file for more
information
>
> Seems that it is fixed in later version of VC++, but I still need to use
VC 6.0.
>
> My question is how can I rewrite this code without disabling the
optimizations
> and without the internal compiler error.
>
> Thanks in advance,
> Manu
>
>



Relevant Pages

  • Re: User defined stack for threads in Linux 2.6.11 + glibc 2.3.5
    ... printf, sleep(), and pthread_exitaren't async-cancel-safe, so the ... behavior is undefined if the thread running that code is actually ... The casting of 'fn' to void* is actually a constraint violation. ... structure that holds the function pointer and the value to pass as its ...
    (comp.programming.threads)
  • Re: returning function pointer
    ... function pointer some_func & meanwhile calls that function and prints ... void some_func ... int main ... Note there are two parameter lists here. ...
    (comp.lang.c)
  • Re: Common misconceptions about C (C95)
    ... I have never seen an example of function pointer ... and void pointer have any interaction. ... Great programmers make ... over the C programming world and only someone of very limited experience ...
    (comp.lang.c)
  • Re: Passing a pointer to a function to the function it points to
    ... void* can't be used because it might not be able to represent a ... Any type of function pointer can portably losslessly point to any ... (Identical to is the easiest form of compatibility.) ...
    (comp.lang.c)
  • Re: void pointer
    ... void; ... void *foo= FOO; ... a function pointer might be bigger than a void * ... to, discard the offset.] ...
    (comp.lang.c)