Bug 21391 - [4.1 Regression] referencing a type via a cast does not emit it for debug (feliminate-unused-debug-types)
Summary: [4.1 Regression] referencing a type via a cast does not emit it for debug (fe...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
: 28099 (view as bug list)
Depends on:
Blocks: 24551
  Show dependency treegraph
 
Reported: 2005-05-04 20:32 UTC by Paul Koning
Modified: 2008-07-04 15:07 UTC (History)
2 users (show)

See Also:
Host:
Target: dwarf-2
Build:
Known to work: 2.95.3 3.3.3 4.2.0
Known to fail: 3.4.0 4.0.0 4.0.4 4.1.0 4.1.3
Last reconfirmed: 2006-02-12 17:57:03


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Koning 2005-05-04 20:32:04 UTC
Test program:

struct foo 
{
    int i;
};

int bar (void)
{
    return ((struct foo *)0x1234)->i;
}

Compile with -g; readelf does NOT show a definition of "struct foo" in the debug
data.

If I compile with  -fno-eliminate-unused-debug-types, the definition does
appear, but in the example program, foo isn't "unused".
Comment 1 Andrew Pinski 2005-05-04 20:36:21 UTC
Confirmed, a regression from 3.3.3.
Comment 2 Andrew Pinski 2005-07-22 21:12:22 UTC
Moving to 4.0.2 pre Mark.
Comment 3 Mark Mitchell 2005-10-31 03:15:08 UTC
Leaving as P2; we really ought to fix this.
Comment 4 Aldy Hernandez 2005-11-16 02:01:47 UTC
I'll take a look at this.
Comment 5 Mark Mitchell 2006-02-24 00:25:52 UTC
This issue will not be resolved in GCC 4.1.0; retargeted at GCC 4.1.1.
Comment 6 Aldy Hernandez 2006-04-11 01:38:09 UTC
Patch that fixes the problem.

http://gcc.gnu.org/ml/gcc-patches/2006-04/msg00380.html
Comment 7 Andrew Pinski 2006-04-26 02:40:30 UTC
Did I mention this fails on powerpc-darwin?
Comment 8 Aldy Hernandez 2006-04-26 15:51:41 UTC
(In reply to comment #7)
> Did I mention this fails on powerpc-darwin?
> 

How so?

pantani:/build/trunk/clean/gcc$ ./cc1 -quiet -g a.c -gstabs
pantani:/build/trunk/clean/gcc$ grep foo a.s        .stabs  "foo:T(0,19)=s4i:(0,1),0,32;;",128,0,0,0
pantani:/build/trunk/clean/gcc$ ./cc1 -quiet -g a.c -gdwarf-2
pantani:/build/trunk/clean/gcc$ grep foo a.s        .ascii "foo\0"
pantani:/build/trunk/clean/gcc$ ./cc1 -quiet -g a.c -g3
pantani:/build/trunk/clean/gcc$ grep foo a.s        .stabs  "foo:T(0,19)=s4i:(0,1),0,32;;",128,0,0,0
Comment 9 Andrew Pinski 2006-04-26 15:56:12 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > Did I mention this fails on powerpc-darwin?
> > 
> 
> How so?

darwin enables -feliminate-unused-debug-symbols by default.
Comment 10 Aldy Hernandez 2006-04-26 16:05:24 UTC
> darwin enables -feliminate-unused-debug-symbols by default.

You mean darwin does NOT enable the option by default, right?
Comment 11 Andrew Pinski 2006-04-26 16:09:50 UTC
(In reply to comment #10)
> > darwin enables -feliminate-unused-debug-symbols by default.
> 
> You mean darwin does NOT enable the option by default, right?

No, there are two different options, and the other one is the stabs version
and not the dwarf2 version.
Comment 12 Aldy Hernandez 2006-04-26 16:14:44 UTC
> No, there are two different options, and the other one is the stabs version
> and not the dwarf2 version.

I'm confused.  What options do you feed to the compiler that exhibit the bug, so I can look into it?
Comment 13 Andrew Pinski 2006-04-26 16:34:42 UTC
(In reply to comment #12)
> I'm confused.  What options do you feed to the compiler that exhibit the bug,
> so I can look into it?

-gstabs+ -feliminate-unused-debug-symbols

(Note the symbols vs types in the option name).
Comment 14 Aldy Hernandez 2006-04-27 00:01:07 UTC
> -gstabs+ -feliminate-unused-debug-symbols

This is a different option than -feliminate-unused-debug-types, so I don't see how this applies.  

The patch I wrote was for eliminate-unused-debug-TYPES.  I suppose if the darwin folks (or anyone else) want the code to apply to eliminate-unused-debug-SYMBOLS as well, they could submit a trivial patch.
Comment 15 Andrew Pinski 2006-05-07 17:11:20 UTC
(In reply to comment #14)
> > -gstabs+ -feliminate-unused-debug-symbols
> 
> This is a different option than -feliminate-unused-debug-types, so I don't see
> how this applies.  

Because the tests fail by default on a secondary target (I am filing a new bug anyways).
Comment 16 Mark Mitchell 2006-05-25 02:32:54 UTC
Will not be fixed in 4.1.1; adjust target milestone to 4.1.2.
Comment 17 Andrew Pinski 2006-06-23 04:53:44 UTC
This was fixed on the mainline.
Comment 18 Andrew Pinski 2006-06-23 04:56:33 UTC
*** Bug 28099 has been marked as a duplicate of this bug. ***
Comment 19 Joseph S. Myers 2008-07-04 15:07:00 UTC
Closing 4.1 branch.