From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25548 invoked by alias); 3 Oct 2014 12:36:08 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 25538 invoked by uid 89); 3 Oct 2014 12:36:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f41.google.com Received: from mail-la0-f41.google.com (HELO mail-la0-f41.google.com) (209.85.215.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 03 Oct 2014 12:36:06 +0000 Received: by mail-la0-f41.google.com with SMTP id pn19so962851lab.0 for ; Fri, 03 Oct 2014 05:36:03 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.199.40 with SMTP id jh8mr5505238lbc.44.1412339763090; Fri, 03 Oct 2014 05:36:03 -0700 (PDT) Received: by 10.112.4.73 with HTTP; Fri, 3 Oct 2014 05:36:03 -0700 (PDT) In-Reply-To: <542E7AE1.2090807@gmail.com> References: <542E5BF1.2070508@gmail.com> <542E75B9.9010504@gmail.com> <542E7AE1.2090807@gmail.com> Date: Fri, 03 Oct 2014 12:36:00 -0000 Message-ID: Subject: Re: std::string clobbers memory when compiling without optimizations From: Jonathan Wakely To: =?UTF-8?Q?Henrik_Mannerstr=C3=B6m?= Cc: gcc-help Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg00018.txt.bz2 On 3 October 2014 11:30, Henrik Mannerstr=C3=B6m wrote: > On 10/03/2014 01:20 PM, Jonathan Wakely wrote: >> My guess is that Sigma holds a dangling reference to some temporary >> object that has gone out of scope, and the function call t2s >> overwrites that stack memory, then when you return to main you go >> through the dangling reference. >> >> Are you sure you're using the Eigen types correctly? > You are right, the auto type does not force the evaluation of Sigma, > which leaves the dangling reference. Yet again I get burned by trying to > combine Eigen and C++11. How would you classify this, could you call it > a bug in Eigen, or just incompatibility with C++11? As Marc says, expression templates are often incompatible with 'auto', that doesn't mean Eigen is incompatible with C++11 in general.