public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: dens@stl.sarov.ru To: gcc-gnats@gcc.gnu.org Subject: libstdc++/9679: Strange behaviour of valarray::apply method Date: Wed, 12 Feb 2003 22:16:00 -0000 [thread overview] Message-ID: <20030212221433.21243.qmail@sources.redhat.com> (raw) >Number: 9679 >Category: libstdc++ >Synopsis: Strange behaviour of valarray::apply method >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Feb 12 22:16:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: dens@stl.sarov.ru >Release: libstdc++-3.2-7 >Organization: >Environment: cat /etc/issue Red Hat Linux release 8.0 (Psyche) Kernel \r on an \m g++ --version g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7) >Description: There is very strange(for me) behaviour of apply method of valarray: #include <valarray> #include <string.h> char bar(char arg) { return tolower(arg); } char foo(char * x) { return toupper(*x); } int main(void) { char * str = new char[7]; strcpy(str,"STRING"); std::valarray<char> y(str, 6); /// Strange behaviour char some = foo(&(y.apply(bar)[0])); return 0; } If I understood correctly then apply method should return valarray<char> object which operator [] should return reference to char (char &). (C++ standard 26.3.2.3 and 26.3.2.7 8.) But in our case this operator returns non-lvalue and I can't get it address. It is very strange for me. >How-To-Repeat: Try to compile attached sample >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="new.cpp" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="new.cpp" I2luY2x1ZGUgPHZhbGFycmF5PgojaW5jbHVkZSA8c3RyaW5nLmg+CmNoYXIgYmFyKGNoYXIgYXJn KQp7CiAgICByZXR1cm4gdG9sb3dlcihhcmcpOwp9CgpjaGFyIGZvbyhjaGFyICogeCkKewogICAg cmV0dXJuIHRvdXBwZXIoKngpOwp9CgppbnQgbWFpbih2b2lkKQp7CgljaGFyICogc3RyID0gbmV3 IGNoYXJbN107CglzdHJjcHkoc3RyLCJTVFJJTkciKTsKCglzdGQ6OnZhbGFycmF5PGNoYXI+IHko c3RyLCA2KTsKCWNoYXIgc29tZSA9IGZvbygmKHkuYXBwbHkoYmFyKVswXSkpOwoJcmV0dXJuIDA7 Cn0K
next reply other threads:[~2003-02-12 22:16 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-02-12 22:16 dens [this message] 2003-02-12 22:36 Gabriel Dos Reis
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=20030212221433.21243.qmail@sources.redhat.com \ --to=dens@stl.sarov.ru \ --cc=gcc-gnats@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).