From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23544 invoked by alias); 29 Jul 2013 14:50:23 -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 23459 invoked by uid 55); 29 Jul 2013 14:50:19 -0000 From: "roystgnr at ices dot utexas.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/57997] Segmentation fault after returning valarray expression from an auto function Date: Mon, 29 Jul 2013 14:50:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: roystgnr at ices dot utexas.edu 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: Message-ID: In-Reply-To: References: 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: 2013-07/txt/msg01413.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57997 --- Comment #4 from Roy Stogner --- I oversimplified the code here to try and make the failure as easy to reproduce as possible. The term here isn't con-fusion, it's "kernel fusion", which the original user code is trying to do with libstdc++ valarray expressions (and VexCL expressions, and Eigen expressions, etc; those cases work); this is essentially the opposite of assuming that expression templates match their input types. To keep equations in their own functions (for maintainability) while still doing parallel evaluation in a single loop (for efficiency), those functions need to return the expression templates which embody their equations. However, this does assume that expression template move constructors (or copy constructors if move constructors aren't defined) don't do a shallow copy of the representations of subexpression objects, and I can't see anything in C++2011 or C++2014 standards drafts *mandating* anything about those constructors. If my amateur standards-lawyering is correct, it would be fair for you to mark this as "wontfix" or whatever bugzilla term signifies "go_bug_standards_committee_instead". On the third hand, there's nothing in the current standard mandating that the implementation *not* be robust when doing kernel fusion with user functions, either. Storing subexpressions by value in _BinBase (specializing to store by reference when the subexpression is just a valarray) might be a sufficient fix.