This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Static variables in template functions
Jason Merrill wrote:
4. Defer the warning until end of function, and then only give it if the
variable turns out to be addressable.
...this would only apply to const variables, of course.
All of this is getting increasingly moot with every passing day, as the
number of systems without weak symbol support is rapidly dwindling,
thankfully. So, we can always decide to consider this an academic
discussion.
Would you want to do this after optimization, so that cases where the
addressing was eliminated by the back end would not result in warnings,
or in the front end based on TREE_ADDRESSABLE?
From your recommendation, you think it better to generate faster code
on these systems (by avoiding the dynamic initialization), even though
that means that the code is sometimes incorrect (in that the variables
are duplicated, and a conforming program can detect the difference). I
understand the argument, and we've done it that way for years, but it
seems somewhat sketchy to me. I'd rather that users have to ask
explicitly for us to generate code at variance with the standard, ala
-ffast-math.
Since these systems are relatively rarely used by the free software
development community, I think we can be sure that there will be lots of
C++ packages that have function-scope statics, and some might even
depend on the one-copy rule. I don't have any evidence of that, though.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304