/* g++ -O2 puts Undefined Global reference for statically defined function */ char *v; static int server1(){ return 0; } void func(){ (v?v:(v=0))[server1()]; }
Save the above into "n.c" and compile it with "g++ -O2 -c n.c", then the "n.o" includes "Undefined Global __Z7server1v" for statically defined function "server1()". I saw this problem in g++ 3.4.2 and 3.4.4. In other versions, the function is expanded inline by default. -- Summary: g++ -O2 generates Undefined Global for statically defined function Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ysato at delegate dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22215