This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/48386] "Cannot declare static function inside another function"
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 31 Mar 2011 13:10:14 +0000
- Subject: [Bug c++/48386] "Cannot declare static function inside another function"
- Auto-submitted: auto-generated
- References: <bug-48386-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48386
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-31 13:10:12 UTC ---
This is not a bug, G++ is correct.
Are you trying to create a static variable?
The rules of C++ say that "B b( A() )" is interpreted as a declaration of a
function called "b" which takes a single parameter and returns "B" ... and as
the error says, you cannot declare a static variable at function scope.
To declare a static variable you need to do:
static B b = B( A() );
or
static B b = A();