[gnu.g++.bug] Problem with declaring pointer to function

c164-cz@katerina.berkeley.edu (Andrew Choi) (03/18/90)

	I discovered a bug (or is it?) while trying to compile the following
simple program:

void print(void)  {  ;  /* dummy statement  */ }

int main(void)
{
	void (*funcPointer)(void);	// This is line 9
	funcPointer = print;

	funcPointer();
	(*funcPointer)();

	return 0;
}

Here is the message the compiler gave me:

bug.C: In function int main ():
bug.C:9: `funcPointer' undeclared (first use this function)
bug.C:9: (Each undeclared identifier is reported only once
bug.C:9: for each function it appears in.)
bug.C:9: parse error before `)'


However, the error message disappeared when I add the following type
declaration:

	typedef void (*PTR_TO_FUNCTION_TYPE)(void);

And then replace line 9 by:

	PTR_TO_FUNCTION_TYPE funcPointer;


Can anyone tell me what I am doing wrong?
By the way, the C++ compiler I was using is g++ (Version 1.37.1), on a
SUN workstation.


Please email response to my account.
Thanks a lot.


Andrew Choi
Internet Address:  c60c-2ca@web.berkeley.edu  or
		   c186cd@cory.berkeley.edu