PR27657 addressed a similar problem but this one is slightly different and remains unsolved: (sid)1556:tbm@em64t: ~/src/a] cat test.c static void sand_window_create_shape (int test) {} static void (* const b) (int test) = sand_window_create_shape; (sid)1557:tbm@em64t: ~/src/a] cat main.c int main() { } (sid)1558:tbm@em64t: ~/src/a] make /usr/lib/gcc-snapshot/bin/gcc -c -o main.o main.c /usr/lib/gcc-snapshot/bin/gcc -c -g -O -o test.o test.c /usr/lib/gcc-snapshot/bin/gcc main.o test.o test.o:(.debug_info+0x49): undefined reference to `sand_window_create_shape' collect2: ld returned 1 exit status make: *** [all] Error 1
Index: dwarf2out.c =================================================================== *** dwarf2out.c (revision 121576) --- dwarf2out.c (working copy) *************** reference_to_unused (tree * tp, int * wa *** 10007,10012 **** --- 10007,10018 ---- if (!node->needed) return *tp; } + else if (DECL_P (*tp) && TREE_CODE (*tp) == FUNCTION_DECL) + { + struct cgraph_node *node = cgraph_node (*tp); + if (!node->needed) + return *tp; + } return NULL_TREE; } honza - does this look sane and can we maybe do this whole function in graph ways?
Fixed on the mainline by Author: hubicka Date: Fri Mar 30 09:03:55 2007 New Revision: 123358 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123358 Log: PR middle-end/PR30700 * dwarf2out.c (reference_to_unused): Ask cgraph for functions availablility; add more sanity checking; ask varpool only about VAR_DECL. Modified: trunk/gcc/ChangeLog trunk/gcc/dwarf2out.c
I'm puzzled why the fix for this PR was checked into mainline instead of gcc 4.2 branch since only gcc 4.2 is marked as known to fail.
If you click on "View Bug Activity" you'll see that the bug used to be marked as 4.2/4.3. Richi changed it to 4.2 only when the patch got committed to mainline.
Does that mean that the patch for mainline wouldn't work on gcc 4.2 branch or that the patch just hasn't been applied to gcc 4.2 branch yet?
The latter.
Subject: Bug 30700 Author: hubicka Date: Tue Apr 17 19:02:09 2007 New Revision: 123922 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123922 Log: PR middle-end/30700 * dwarf2out.c (reference_to_unused): Ask cgraph for functions availablility; add more sanity checking; ask varpool only about VAR_DECL. Modified: branches/gcc-4_2-branch/gcc/ChangeLog branches/gcc-4_2-branch/gcc/dwarf2out.c
Fixed.