This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Static variables in template functions
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: mark at codesourcery dot com
- Cc: libstdc++ at gcc dot gnu dot org, jason at redhat dot com
- Date: Sun, 17 Apr 2005 10:26:10 +0100
- Subject: Re: Static variables in template functions
- Organization: CodeSourcery LLC
- References: <200504170430.j3H4U5fk017819@sirius.codesourcery.com>
Mark Mitchell wrote:
1. Adopt a coding standard for V3 that forbids static variables with
constant initializers in template/inline functions. Downside:
painful for V3 developers.
And also pessimizes systems _with_ weak support. (Though as Paolo
says, this instance is not performace critical.)
3. Modify the compiler to initialize such variables dynamically,
thereby eliminating the problem. Downside: pessimizes code.
I agree with your reasoning that this is the appropriate solution.
[Although, in general, the compiler is not permitted to turn static
initialization into dynamic initialization, I think for such
function-scope constant initializers, a program cannot tell the
difference -- but make sure we still treat the variable as a
constan for the remainder of the function.]
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk