This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Static variables in template functions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]