From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9160 invoked by alias); 29 Nov 2014 05:15:54 -0000 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 Received: (qmail 9144 invoked by uid 48); 29 Nov 2014 05:15:50 -0000 From: "fhansen at rocketmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug regression/64112] New: Optimized away string literal leads to a core dump Date: Sat, 29 Nov 2014 05:15:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: regression X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fhansen at rocketmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-11/txt/msg03375.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64112 Bug ID: 64112 Summary: Optimized away string literal leads to a core dump Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: regression Assignee: unassigned at gcc dot gnu.org Reporter: fhansen at rocketmail dot com The following program prints "str" when compiled without optimizations but core dumps when compiled with GCC 4.8.0 and optimization level -O2. The compilation command used: g++ -O2 test.cpp #include class X { public: X(const char* str) : str_(str) {} const char* str_; }; class Y { public: Y(const X& x) : x_(x) {} void print() const { printf("%s\n", x_.str_); } private: const X& x_; }; int main() { Y y("str"); y.print(); } This appears to be a regression in 4.8. Version and target: g++ (GCC) 4.8.0 i686-pc-linux-gnu