The following code compiles, but won't link: #include <iostream> using namespace std;
class C { public: C() { static void *labelref = &&label; goto *labelref; label: cout << "hello" << endl; } }; int main (int argc, char **argv) { C inst = C(); return 0; } $ g++ label.cxx /tmp/ccirWO3W.o:(.data._ZZN1CC1EvE8labelref[C::C()::labelref]+0x0): undefined reference to `.L11' collect2: ld returned 1 exit status -- Summary: Using static label reference in c++ class constructor produces wrong code Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mark at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41090