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


Jason Merrill wrote:

I was only suggesting that we don't warn for const, non-addressed
variables, which I believe was the case in question here.  For others I
would leave the warning.

What I proposed was that on affected platforms we make all initializations (independently of const-ness/addressed-ness) dynamic, and thereby eliminate the warning, as the compiler would then be generating correct code.


We could in theory refine that to do dynamic initializations only for variables that are either non-const or addressed, and still do static initializations for the remainder. However, I don't think we can easily implement that refinement, as we decide whether to do a dynamic initialization before we have information about addressed-ness.

I'm not sure if we're talking past each other or not, so I'll try to make a clearer statement.

I'm proposing that on platforms without weak symbols we perform all initializations of function-scoped static data dynamically, thereby implementing the semantics required by the standard, even though it is sub-optimal in terms of performance.

If I understand correctly, your position is that we should instead, continue to have the current behavior (generate incorrect code, with a warning), except that we should avoid issuing the warning in the case of a const, non-addressed variable, as in that case the code we generate is in fact correct.

Do I have it right?

Thanks,

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


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