Bug 79042
| Summary: | g++ crashes when locally defined class without virtual destructor is new'd | ||
|---|---|---|---|
| Product: | [Retired] Red Hat Linux | Reporter: | Steve Zastrow <steven.zastrow> |
| Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
| Status: | CLOSED RAWHIDE | QA Contact: | Brian Brock <bbrock> |
| Severity: | low | Docs Contact: | |
| Priority: | medium | ||
| Version: | 8.0 | ||
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | i686 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2003-02-19 16:10:40 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: | |||
This works in 8.0 / gcc 3.2 unoptimised If you optimise it this triggers an infinite loop in the compiler.. Cannot reproduce this with gcc-3.2.2-1 from rawhide. |
From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0) Description of problem: I've been able to get g++ to crash when a method of a class is called that new's an instance of a class that is defined within the method, and where this locally defined class does not have a destructor and the class it is derived from has a virtual destructor. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. Put the following code into a file named "test.cpp" (this is small enough that I thought I could include it here): class BaseClass { public: virtual ~BaseClass () {}; }; class Test { public: static void Foo() { class LocalClass: public BaseClass { public: // ~LocalClass() {}; }; new LocalClass; } }; main() { Test::Foo(); }; 2. Compile it as follows: g++ -Wall -g -O -c -w -D_REENTRANT -Wunused -fsigned-char -fsigned-bitfields test.cpp Actual Results: The following message was displayed: test.cpp: In method `Test::Foo ()::LocalClass::~LocalClass ()': test.cpp:24: Internal error: Segmentation fault. Please submit a full bug report. See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions. Expected Results: The code should have compiled without errors. Additional info: The workaround for this problem is to write a destructor for LocalClass. While this fixes the problem, it is completely unnecessary to have a destructor in my case.