Bug 129841 (IT#45246)

Summary: [RHEL3 U3] missing debug info for nested class of template
Product: Red Hat Enterprise Linux 3 Reporter: Alexandre Oliva <aoliva>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: tao
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-09-15 01:17:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 123574    
Attachments:
Description Flags
Patch that fixes the problem none

Description Alexandre Oliva 2004-08-13 07:52:49 UTC
walkert@zaphod:foo$ cat bar.C
template<class T> struct X
{
    struct Y
    {
        T t;
    };
                                                                     
          
    X( ) : y( new Y ) { }
                                                                     
          
    Y* y;
};
                                                                     
          
int main( unsigned int, char** )
{
    X<int> x;  // break here
}
                                                                     
          
walkert@zaphod:foo$ gdb bar
(gdb) break main
Breakpoint 1 at 0x80484a8: file bar.C, line 15.
(gdb) run
Starting program: /ms/.global/ny.u/user/w/walkert/foo/bar
 
Breakpoint 1, main () at bar.C:15
15          X<int> x;  // break here
(gdb) print *x.y
$3 = <incomplete type>

Comment 2 Alexandre Oliva 2004-08-13 08:05:47 UTC
Created attachment 102688 [details]
Patch that fixes the problem

This problem was introduced with the patch at
http://gcc.gnu.org/ml/gcc/2003-02/msg02052.html (rth tweaked it a bit before
checking it in, but didn't post the exact patch).  It wasn't present in early
3.2 releases, and the patch was never added to 3.3, that uses a completely
different approach to avoid emitting unused debug information.

The problem is that a die for Y is initially created for the declaration only,
and add the definition die only later.	The problem is that all references to
the type point to the declaration node, not to the specification one, so the
specification one ends up being regarded as unused, and removed.

The attached patch has an assumption I'm not entirely sure we're entitled to
make, namely, that as we walk the comp unit dies in the sequence they were
generated, when we get to the die for the specification, we'll have already
marked the declaration node should it be needed.  One the good side, should the
assumption not hold, we'll end up with debug info that is no worse than what we
have now.

I've verified that the patch fixes the reported problem, and that it can build
all of libgcc and libstdc++ with debug info with the patch, but I have only
just started regression testing.

Comment 3 Alexandre Oliva 2004-08-13 09:18:40 UTC
Regression testing on i686 completed.

Comment 4 Larry Troan 2004-09-15 01:17:27 UTC
From Issue Tracker:
Event posted 08-13-2004 11:53am by thomas.walker  	
Looks good in initial testing.
--------------------------------------

Event posted 09-02-2004 10:03am by fhirtz  	
We've been able to get the priority compiler fixes in the U3 release,
thus this has been included in the gcc-3.2.3-42 release with U3.

CHANGING THIS BZ TO RESOLVED=CURRENTRELEASE FOR RHEL3 U3 (per fhirtz)