The following code compiles, but the linker complains of an undefined reference. If I comment out the line with *xx* it will link. Is this a known and/or fixed bug in later versions of gcc?
SLES 10.2 gcc --version gcc (GCC) 4.1.2 20070115 (SUSE Linux) replace.cpp: #include <algorithm> #include <vector> class A { private: const static int k1 = 1; std::vector<int> mv; public: A(int p); }; A::A(int p) : mv(1,p) { int x = mv.back() + k1; // k1 ok here std::replace(mv.begin(), mv.end(), 0, k1); // *xx* linker can't find k1 here } int main(int argc, char **argv) { A a(0); return 0; } > g++ replace.cpp /tmp/ccIdfZfH.o: In function `A::A(int)': replace.cpp:(.text+0xb8): undefined reference to `A::k1' /tmp/ccIdfZfH.o: In function `A::A(int)': replace.cpp:(.text+0x1f2): undefined reference to `A::k1' collect2: ld returned 1 exit status _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus