This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/44577] static local variables in class template methods are not optimized-away if not used
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jun 2010 13:25:36 -0000
- Subject: [Bug c++/44577] static local variables in class template methods are not optimized-away if not used
- References: <bug-44577-19300@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from redi at gcc dot gnu dot org 2010-06-18 13:25 -------
If class_template<int>::class_template is instantiated in another translation
unit then it needs to refer to the same 's' ... but since the constructor calls
a static function, an instantiation in another TU would violate the ODR, which
would be undefined (no diagnostic required) so by that argument the compiler
could assume no other instantiations and therefore no valid way for another TU
to refer to 's'
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44577