[gnu.g++.bug] G++ 1.34.1: Bug with function prototypes

rfrench@ATHENA.MIT.EDU ("Robert S. French") (04/21/89)

The file:

	void foo(int (*pfri)());

causes g++ 1.34.1 to error out with:

g++ version 1.34.1
 /mit/gnu/vaxlib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dvax -Dunix -D__vax_
_ -D__unix__ /tmp/foo.c /tmp/cc000608.cpp
GNU CPP version 1.34
 /mit/gnu/vaxlib/gcc-c++ /tmp/cc000608.cpp -quiet -dumpbase /tmp/foo.c -version 
-o /tmp/cc000608.s
GNU C++ version 1.34.1 (vax) compiled by GNU C version 1.34.
/tmp/foo.c:1: `pfri' undeclared, outside of functions
/tmp/foo.c:1: bad parameter list specification for function `foo'


The same file goes through gcc 1.34 fine.

			Rob

tiemann@YAHI.STANFORD.EDU (Michael Tiemann) (04/21/89)

   Date: Thu, 20 Apr 89 21:50:28 EDT
   From: "Robert S. French" <rfrench@athena.mit.edu>
   Sender: rfrench@athena.mit.edu


   The file:

	   void foo(int (*pfri)());

   causes g++ 1.34.1 to error out with:

   [ ... ]

Yes.  This is a documented lossage of GNU C++.  If you want to know
why it loses, look in g++.texinfo, and search for the string

inherently ambiguous

This phrase describes the C++ grammar, and the containing paragraph
explains why I decided to not waste time trying to deal with it.

Michael

schmidt@zola.ics.uci.edu (Doug Schmidt) (04/21/89)

In article <8904210150.AA00613@OLIVER.MIT.EDU> rfrench@ATHENA.MIT.EDU ("Robert S. French") writes:
++ 
++ The file:
++ 
++ 	void foo(int (*pfri)());
++ 
++ causes g++ 1.34.1 to error out with:
++ 
++ g++ version 1.34.1
++  /mit/gnu/vaxlib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dvax -Dunix -D__vax_
++ _ -D__unix__ /tmp/foo.c /tmp/cc000608.cpp
++ GNU CPP version 1.34
++  /mit/gnu/vaxlib/gcc-c++ /tmp/cc000608.cpp -quiet -dumpbase /tmp/foo.c -version 
++ -o /tmp/cc000608.s
++ GNU C++ version 1.34.1 (vax) compiled by GNU C version 1.34.
++ /tmp/foo.c:1: `pfri' undeclared, outside of functions
++ /tmp/foo.c:1: bad parameter list specification for function `foo'
++ 
++ 
++ The same file goes through gcc 1.34 fine.

This is a known problem with g++ (see g++.texinfo).  Don't expect a
fix anytime soon.  The work around is as follows for your particular
case:

void foo(auto int (*pfri)());
         ^^^^
         note this...

Yes this is annoying, yes it would be nice if it worked `as expected',
no I don't have a good fix for this, and if you figure one out please
let us know! ;-)

Doug

p.s. Note that a similar problem occurs within functions, i.e.,

foo ()
{
  int (*i)();        
}

also fails with g++.  The fix is the same here too:

foo ()
{
  auto int (*i)();        
}

(or use a typedef).
--
On a clear day, under blue skies, there is no need to seek.
And asking about Buddha                +------------------------+
Is like proclaiming innocence,         | schmidt@ics.uci.edu    |
With loot in your pocket.              | office: (714) 856-4043 |