This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Bug! when a function is the parameter of another function.
- To: "Peng-Sheng Chen" <pschen at puma dot cs dot nthu dot edu dot tw>
- Subject: Re: Bug! when a function is the parameter of another function.
- From: "Timothy J. Wood" <tjw at omnigroup dot com>
- Date: Sun, 05 Mar 2000 13:16:41 -0800
- Cc: <gcc-bug at gcc dot gnu dot org>, <gcc at gcc dot gnu dot org>
Do you get correct results if you do this as follows?
#include <stdio.h>
void func1(void)
{
printf("hello world\n");
}
void func2(void (*f)())
{
f();
}
int main(void)
{
func2(&func1);
return 1;
}
Also, I never use the '&' operator on functions ... just the function
name. I'm not sure which is standard, but both seem to work on this example
(probably because there is no way to pass a function by value, it is always
passed by reference).
From: "Peng-Sheng Chen" <pschen@puma.cs.nthu.edu.tw>
>If I write a C program which include a function is the parameter of
>another function, gcc will produce wrong assembly-code.
-tim