I get the following link error with 4.3 and -O -g: $ gcc -c -g -O test.c -o test.o $ gcc -o m m.c test.o test.o:(.debug_info+0x539): undefined reference to `.L4' collect2: ld returned 1 exit status test.c: #include <netdb.h> #include <stdio.h> #include <malloc.h> typedef struct _hostEntry { struct _hostEntry *next; int type; } HostEntry; typedef struct _displayEntry { struct _displayEntry *next; int type; int chooser; HostEntry *hosts; } DisplayEntry; char* name; char *ReadWord(FILE *file) { return name; } static HostEntry * ReadHostEntry (FILE *file) { char *hostOrAlias; HostEntry *h; struct hostent *hostent; tryagain: hostOrAlias = ReadWord (file); if (!hostOrAlias) return NULL; h = (HostEntry *) malloc (sizeof (DisplayEntry)); if (!hostent) { free ((char *) h); goto tryagain; } return h; } static DisplayEntry * ReadDisplayEntry (FILE *file) { DisplayEntry *d; HostEntry *h, **prev; struct hostent *hostent; switch (hostent->h_addrtype) { default: break; } prev = &d->hosts; while ((h = ReadHostEntry (file))) { if (h->type == 3) { d->chooser = 1; } else { *prev = h; prev = &h->next; } } return d; } int ScanAccessDatabase (FILE *file) { ReadDisplayEntry (file); } m.c: int main() { }
This problem was introduced between 20070303 and 20070326.
Looks like the kind of bug that cfglayout mode might introduce. Will investigate...
Which target is this, BTW?
I've seen it on x86_64 and ia64.
At the end of loop2, the tryagain label is turned into a deleted label note. This happens because the label has zero uses left in cfglayout. There are only unconditional jumps to it, unconditional jumps are removed when going into cfglayout mode (any edge can fall through to any block), and apparently we rebuild jump labels. Which shouldn't happen, I think. Anyway, definitely mine.
Index: cfgcleanup.c =================================================================== --- cfgcleanup.c (revision 123362) +++ cfgcleanup.c (working copy) @@ -2034,6 +2034,8 @@ try_optimize_cfg (int mode) reorder_insns_nobb (label, label, bb_note); BB_HEAD (b) = bb_note; + if (BB_END (b) == bb_note) + BB_END (b) = label; } if (dump_file) fprintf (dump_file, "Deleted label in block %i.\n",
This patch works for me.
Subject: Bug 31391 Author: steven Date: Sun Apr 1 19:26:00 2007 New Revision: 123406 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123406 Log: PR rtl-optimization/31391 * cfgcleanup.c (try_optimize_cfg): If a removed label is turned into a DELETED_LABEL note, and the label is in an empty basic block, update BB_END as well as BB_HEAD. Modified: trunk/gcc/ChangeLog trunk/gcc/cfgcleanup.c
.