public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug libstdc++/50119] New: copy_n advances InputIterator one more time than necessary @ 2011-08-18 14:57 cubbi at cubbi dot org 2011-08-18 15:11 ` [Bug libstdc++/50119] " paolo.carlini at oracle dot com ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: cubbi at cubbi dot org @ 2011-08-18 14:57 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50119 Bug #: 50119 Summary: copy_n advances InputIterator one more time than necessary Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: cubbi@cubbi.org The naive implementation of std::copy_n() incorrectly increments InputIterator one more time than needed, which fails with single-pass input iterators such as istream_iterator Test program: #include <algorithm> #include <vector> #include <sstream> #include <iterator> #include <iostream> int main() { std::istringstream s("1 2 3 4 5"); std::vector<int> v; copy_n(std::istream_iterator<int>(s), 2, back_inserter(v)); copy_n(std::istream_iterator<int>(s), 2, back_inserter(v)); copy(v.begin(), v.end(), std::ostream_iterator<int>(std::cout, " ")); std::cout << '\n'; } Output with GCC 4.5.3 and 4.7.0-alpha20110716 1 2 4 5 expected output: 1 2 3 4 Similar bug was fixed in LLVM's libc++ in february 2011, the fix is straightforward: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20110221/039404.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/50119] copy_n advances InputIterator one more time than necessary 2011-08-18 14:57 [Bug libstdc++/50119] New: copy_n advances InputIterator one more time than necessary cubbi at cubbi dot org @ 2011-08-18 15:11 ` paolo.carlini at oracle dot com 2011-08-18 16:36 ` [Bug libstdc++/50119] [C++0x] " paolo at gcc dot gnu.org 2011-08-18 16:41 ` paolo.carlini at oracle dot com 2 siblings, 0 replies; 4+ messages in thread From: paolo.carlini at oracle dot com @ 2011-08-18 15:11 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50119 Paolo Carlini <paolo.carlini at oracle dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2011-08-18 AssignedTo|unassigned at gcc dot |paolo.carlini at oracle dot |gnu.org |com Target Milestone|--- |4.7.0 Ever Confirmed|0 |1 --- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-08-18 15:03:26 UTC --- Ok. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/50119] [C++0x] copy_n advances InputIterator one more time than necessary 2011-08-18 14:57 [Bug libstdc++/50119] New: copy_n advances InputIterator one more time than necessary cubbi at cubbi dot org 2011-08-18 15:11 ` [Bug libstdc++/50119] " paolo.carlini at oracle dot com @ 2011-08-18 16:36 ` paolo at gcc dot gnu.org 2011-08-18 16:41 ` paolo.carlini at oracle dot com 2 siblings, 0 replies; 4+ messages in thread From: paolo at gcc dot gnu.org @ 2011-08-18 16:36 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50119 --- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-08-18 16:32:31 UTC --- Author: paolo Date: Thu Aug 18 16:32:23 2011 New Revision: 177871 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177871 Log: 2011-08-18 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/50119 * include/bits/stl_algo.h (__copy_n(_InputIterator, _Size, _OutputIterator, input_iterator_tag)): Fix. * testsuite/25_algorithms/copy_n/50119.cc: New. Added: trunk/libstdc++-v3/testsuite/25_algorithms/copy_n/50119.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/stl_algo.h ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/50119] [C++0x] copy_n advances InputIterator one more time than necessary 2011-08-18 14:57 [Bug libstdc++/50119] New: copy_n advances InputIterator one more time than necessary cubbi at cubbi dot org 2011-08-18 15:11 ` [Bug libstdc++/50119] " paolo.carlini at oracle dot com 2011-08-18 16:36 ` [Bug libstdc++/50119] [C++0x] " paolo at gcc dot gnu.org @ 2011-08-18 16:41 ` paolo.carlini at oracle dot com 2 siblings, 0 replies; 4+ messages in thread From: paolo.carlini at oracle dot com @ 2011-08-18 16:41 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50119 Paolo Carlini <paolo.carlini at oracle dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-08-18 16:36:16 UTC --- Done, thanks! ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-18 16:36 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-08-18 14:57 [Bug libstdc++/50119] New: copy_n advances InputIterator one more time than necessary cubbi at cubbi dot org 2011-08-18 15:11 ` [Bug libstdc++/50119] " paolo.carlini at oracle dot com 2011-08-18 16:36 ` [Bug libstdc++/50119] [C++0x] " paolo at gcc dot gnu.org 2011-08-18 16:41 ` paolo.carlini at oracle dot com
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).