Bug! when a function is the parameter of another function.
Timothy J. Wood
tjw@omnigroup.com
Sun Mar 5 13:16:00 GMT 2000
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
More information about the Gcc
mailing list