From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21893 invoked by alias); 9 Jan 2013 04:15:59 -0000 Received: (qmail 21558 invoked by uid 48); 9 Jan 2013 04:15:36 -0000 From: "f.heckenbach@fh-soft.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55893] [4.7/4.8 Regression][C++11] runtime segfault with static const object with virtual destructor Date: Wed, 09 Jan 2013 04:15:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: f.heckenbach@fh-soft.de X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jason at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.3 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00726.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55893 --- Comment #6 from Frank Heckenbach 2013-01-09 04:15:35 UTC --- (In reply to comment #5) > Caused by http://gcc.gnu.org/PR49673 I believe. Perhaps instead of testing > whether TYPE_NEEDS_CONSTRUCTING we need to check if the type has non-trivial > destructor (is a user destructor on const qualified vars allowed to store into > the var anywhere?) According to http://stackoverflow.com/questions/2271046/if-changing-a-const-object-is-undefined-behavior-then-how-do-constructors-and-de (see references in the accepted answer), it is. So perhaps, if any user destructor exists (direct or indirect through base classes or fields), the object cannot be stored in read-only data (unless the compiler can prove that it's still safe). If none exists, then updating the vtable pointer is unneeded and it can be stored in read-only data.