On platforms without weak symbols, we presently emit statically initialized function-scope static variables with internal linkage, even in functions with vague linkage, and issue a warning indicating that, while the standard requires that there be only one copy of the variable, there will in fact be multiple copies in the user program.
In this thread: http://gcc.gnu.org/ml/libstdc++/2005-04/msg00152.html it was agreed that we should instead dynamically initialized all non-const variables (thereby ensuring correct semantics), and continue to emit static initializers only for const variables. For const variables whose addresses are not taken, we should not warn, as there is no way for the program to tell that there are multiple copies of the variable. -- Summary: Improve handling of function-scope statics on platforms without weak symbols Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mmitchel at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21139