From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3612 invoked by alias); 8 Oct 2010 15:59:12 -0000 Received: (qmail 3601 invoked by uid 22791); 8 Oct 2010 15:59:11 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,MISSING_MID X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Oct 2010 15:59:07 +0000 From: "bredelin at ucla dot edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/45699] [4.6 Regression] Incorrect copy constructor generated with -O X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: bredelin at ucla dot edu X-Bugzilla-Status: NEW X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.0 X-Bugzilla-Changed-Fields: 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 Date: Fri, 08 Oct 2010 15:59:00 -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 X-SW-Source: 2010-10/txt/msg00742.txt.bz2 Message-ID: <20101008155900.OAyJQ4bwtXefCoodh9GRPOU4XcUAPbdQj-SIo4obb2w@z> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45699 --- Comment #8 from bredelin at ucla dot edu 2010-10-08 15:58:49 UTC --- When you say segfault, I presume you mean abort? When I use the debugger, the problem appears to be in the call to new Parameters(*P); On x86_64, the problem occurs as follows: (x86_32 is different) In the copy constructor, Parameters::SuperModel2 is constructed OK. Then the copy constructor for Parameters::Probability_Model is called, which calls the copy constructor for Probability_Model::Model2, which calls the copy constructor for Model2::vector. In the (synthesized) copy constructor vector::vector(const vector& __x), the debugger claims that "this" and "__x" are both optimized out, and won't let me inspect anything. The SIGABORT actually occurs because the __x has a __x.size() of 18446726482060379005. It should have a size of 0. (I can't call __x.size(), but I can access __n, which is initialized from __x.size()).