Bug 22034 - [4.1 Regression] ICE on valid (local class), dwarf2
Summary: [4.1 Regression] ICE on valid (local class), dwarf2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P2 critical
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, monitored
: 22583 23045 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-06-12 13:11 UTC by Jan van Dijk
Modified: 2005-08-18 19:14 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-06-30 13:11:37


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan van Dijk 2005-06-12 13:11:05 UTC
Consider the following reduction from a wxWidgets source module: 
 
const char* GetAssertStackTrace() 
{ 
    struct StackDump 
    { 
        virtual void OnStackFrame() {} 
        const char* GetStackTrace() const; 
    }; 
    StackDump dump; 
    return dump.GetStackTrace(); 
} 
const char* stackTrace = GetAssertStackTrace(); 
 
 
Compiled with today's trunk with debugging enabled (-g), this gives: 
 
jan@nbelvis:~/src/gcc-head $ g++ -g appbase.cpp 
appbase.cpp:12: internal compiler error: tree check: expected class 
?declaration?, have?type? (record_type) in lookup_decl_die, at dwarf2out.c:5457 
 
Strangely enough, almost any change to the code above also fixes this problem: 
removing the class declaration outside the function body, removing the empty 
body of OnStackFrame, making that function non-virtual, adding a virtual 
destructor (as one should), ...
Comment 1 Andrew Pinski 2005-06-12 13:44:49 UTC
Confirmed, this is a recent regression, it worked with "4.1.0 20050530"
Comment 2 Volker Reichelt 2005-06-16 08:47:44 UTC
Even shorter testcase:

==========================
void foo()
{
    struct A
    {
        virtual ~A() {}
    } a;
}
==========================
Comment 3 Volker Reichelt 2005-06-16 09:33:02 UTC
Honza, this was caused by your patch
http://gcc.gnu.org/ml/gcc-cvs/2005-06/msg00388.html

Could you please have a look?
Comment 4 Andrew Pinski 2005-07-21 07:09:53 UTC
*** Bug 22583 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2005-07-24 17:29:30 UTC
*** Bug 23045 has been marked as a duplicate of this bug. ***
Comment 6 dank 2005-08-07 06:23:18 UTC
Still there in gcc-4.1-20050806.
Comment 7 Gabriel Dos Reis 2005-08-09 09:41:06 UTC
local classes are pervasive in C++.
Comment 8 GCC Commits 2005-08-18 15:25:45 UTC
Subject: Bug 22034

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	hubicka@gcc.gnu.org	2005-08-18 15:25:07

Modified files:
	gcc            : cgraphunit.c ChangeLog 

Log message:
	PR c++/22034
	* cgraphunit.c (cgraph_varpool_assemble_pending_decls): Emit debug
	info only for local statics, not for member variables.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cgraphunit.c.diff?cvsroot=gcc&r1=1.126&r2=1.127
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9771&r2=2.9772

Comment 9 Andrew Pinski 2005-08-18 19:14:14 UTC
Fixed.