This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/36959] [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
- From: "mmitchel at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Sep 2008 21:59:18 -0000
- Subject: [Bug c++/36959] [4.2/4.3/4.4 Regression] C++ front-end causing a static inline function to be emitted
- References: <bug-36959-6528@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from mmitchel at gcc dot gnu dot org 2008-09-20 21:59 -------
I suspect that things have been improved so that this code is no longer
required. My expectation is that in the past we only emitted the static when
we emitted the function body, so the code made sense. But, now, with the
cgraph infrastructure, the compiler is probably perfect capable of emitting a
variable without its containing function.
Andrew raises a good point about -frepo. The interesting question is what
happens if there is an undefined referenced to the variable, but not the
function; does collect2 arrange that we actually emit the function?
For example:
test.h
------
template <typename T> void * f(T) {
static int i;
}
a.C
---
#include "test.h"
int* p = f(3);
int main() {}
With -O2 -frepo, does this link? I'd expect that we end up with an undefined
referenced to f<int>::i in a.o, but that this variable isn't listed in the set
of things that could be generated by recompiling a.C, so we lose.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36959