When a static-const primitive is passed as a const-ref argument to function with a variadic template arglist, GCC generates code that references the static-const primitive, and optimizes away the static-const primitive, resulting in a "undefined reference" linker error. /* Start of Example */ class Foo { public: template <typename... T> static void foo(const T&... blah) { } }; class Test { public: static const int tmp = 1; }; int main(int argc, char** argv) { Foo::foo(Test::tmp); // THIS COMPILES BUT LINKER FAILS //Foo::foo(static_cast<int>(Test::tmp)); // THIS COMPILES AND LINKS FINE } /* END OF EXAMPLE */ LINKER ERROR: /tmp/ccfV1opu.o: In function `main': tmp.cc:(.text+0x10): undefined reference to `Test::tmp' collect2: ld returned 1 exit status Since static cast of the static-const int primitive to an int fixes the problem, it's clear that GCC is somehow mishandling how it optimizes away Test::tmp even though it's being used as a const int& in Foo::foo(...)
Created attachment 19686 [details] example of c++0x code that generates linker error compiled with ver 4.3.4 g++ and args -std=c++0x
Ignore. Close bug. Found the issue here: http://hellewell.homeip.net/phillip/blogs/index.php?entry=entry060314-000000
N.B. duplicate of Bug 14404