public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "roystgnr at ices dot utexas.edu" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-57997-4-vvxFEj6y5r@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-57997-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57997

--- Comment #4 from Roy Stogner <roystgnr at ices dot utexas.edu> ---
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.


  parent reply	other threads:[~2013-07-29 14:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-26 22:07 [Bug libstdc++/57997] New: " roystgnr at ices dot utexas.edu
2013-07-26 22:53 ` [Bug libstdc++/57997] " paolo.carlini at oracle dot com
2013-07-26 23:27 ` gdr at gcc dot gnu.org
2013-07-26 23:29 ` gdr at gcc dot gnu.org
2013-07-29 14:50 ` roystgnr at ices dot utexas.edu [this message]
2013-07-29 14:59 ` paolo.carlini at oracle dot com
2013-08-01 17:12 ` roystgnr at ices dot utexas.edu
2013-08-01 18:45 ` paolo.carlini at oracle dot com
2014-10-13 15:04 ` redi at gcc dot gnu.org
2014-10-13 15:49 ` glisse at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-57997-4-vvxFEj6y5r@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).