public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "helloworld922 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/63314] New: valarray mask/indices refers to temporary Date: Fri, 19 Sep 2014 16:41:00 -0000 [thread overview] Message-ID: <bug-63314-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63314 Bug ID: 63314 Summary: valarray mask/indices refers to temporary Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: blocker Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: helloworld922 at hotmail dot com std::mask_array appears to be holding a reference to the underlying _M_data of the mask std::valarray. This is a problem when the mask valarray is a temporary: std::valarray<int> data = {1,4,0,2,5}; std::mask_array<int> marr = data[data <= 2]; Here, the data <= 2 mask is a temporary and sarr will have an invalid address for for the mask _M_data. Trying to do anything with mask_array at this point would have problems, i.e.: marr = 11; will be undefined behavior. Similarly, there is an identical issue with std::indirect_array: std::indirect_array<int> iarr = data[std::valarray<size_t>({1,2,4})]; Because the underlying _M_data has no ownership in mask_array/indirect_array, there are additional problems when trying to return the given type: std::mask_array<int> doit(const std::valarray<int> &data) { std::valarray<size_t> idx = {1,2,3}; return data[idx]; } It is unclear to me if this behavior is allowed by the standard, but it certainly looks fishy, especially given that the deduced type for this: auto marr = data[data <= 2]; is std::mask_array
next reply other threads:[~2014-09-19 16:41 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-09-19 16:41 helloworld922 at hotmail dot com [this message] 2014-09-19 23:18 ` [Bug libstdc++/63314] " redi 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-63314-4@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: linkBe 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).