Xref: utzoo comp.lang.c++:4354 gnu.g++:337
Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcvax!unido!isaak!isaak.uucp!schwarze
From: schwarze@isaak.uucp (Jochen Schwarze)
Newsgroups: comp.lang.c++,gnu.g++
Subject: Automatic variables of type pointer to function?
Message-ID: <1117@isaak.UUCP>
Date: 11 Aug 89 20:08:36 GMT
Sender: news@isaak.UUCP
Reply-To: schwarze@isaak.uucp (Jochen Schwarze)
Organization: ISA GmbH, Stuttgart, West-Germany
Lines: 41


Hello!

I just noticed, that it is obviously not possible to declare an
automatic variable of type pointer to function explicitly without
using a typedef. All other cases, both global and local static, and
even automatic declarations using a typedef work as expected.

Look at the following:


    int func() { return 0; }

    typedef int (*PFI)();

    int (*global_explicit)()    = &func;
    PFI global_typedef          = &func;

    main()
    {
	static PFI static_typedef       = &func;
	static int (*static_explicit)() = &func;

	PFI auto_typedef                = &func;
	int (*auto_explicit)()          = &func;    // error
    }


Although all of the above declarations with initializations seem to
be valid, both AT&T cfront 1.2 and g++ 1.35.0 complain about the
last declaration:

    cfront: error: auto_explicit is undefined
    g++: `auto_explicit' was not declared

What's wrong about the above code? What am I missing?
Or are the compliers the ones to blame?
Jochen Schwarze, ISA GmbH, Stuttgart, West Germany

UUCP:   schwarze@isaak.uucp
BITNET: schwarze%isaak.uucp@unido.bitnet