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(...) -- Summary: const-ref argument in a variadic template arglist is mishandled Product: gcc Version: 4.3.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: navin dot kumar at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42840