public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/50529] New: std::vector::erase invokes undefined behavior with empty range
@ 2011-09-27  0:45 delong.j at fb dot com
  2011-09-27  1:56 ` [Bug libstdc++/50529] [C++0x] " paolo.carlini at oracle dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: delong.j at fb dot com @ 2011-09-27  0:45 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50529
           Summary: std::vector::erase invokes undefined behavior with
                    empty range
    Classification: Unclassified
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: delong.j@fb.com


If you call vector erase() with an empty range, it invokes std::move() with an
output iterator inside of the source range.  (I.e. it tries to move all the
elements onto themselves.)  This causes problems if some of the elements don't
support self move-assignment (e.g. if they are other std::vectors).


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/50529] [C++0x] std::vector::erase invokes undefined behavior with empty range
  2011-09-27  0:45 [Bug libstdc++/50529] New: std::vector::erase invokes undefined behavior with empty range delong.j at fb dot com
@ 2011-09-27  1:56 ` paolo.carlini at oracle dot com
  2011-09-27  1:57 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-27  1:56 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011-09-27
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
            Summary|std::vector::erase invokes  |[C++0x] std::vector::erase
                   |undefined behavior with     |invokes undefined behavior
                   |empty range                 |with empty range
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-27 00:38:24 UTC ---
Ok, thanks, it's also an optimization.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/50529] [C++0x] std::vector::erase invokes undefined behavior with empty range
  2011-09-27  0:45 [Bug libstdc++/50529] New: std::vector::erase invokes undefined behavior with empty range delong.j at fb dot com
  2011-09-27  1:56 ` [Bug libstdc++/50529] [C++0x] " paolo.carlini at oracle dot com
@ 2011-09-27  1:57 ` paolo.carlini at oracle dot com
  2011-09-27  2:56 ` paolo at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-27  1:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-27 00:45:12 UTC ---
deque too


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/50529] [C++0x] std::vector::erase invokes undefined behavior with empty range
  2011-09-27  0:45 [Bug libstdc++/50529] New: std::vector::erase invokes undefined behavior with empty range delong.j at fb dot com
  2011-09-27  1:56 ` [Bug libstdc++/50529] [C++0x] " paolo.carlini at oracle dot com
  2011-09-27  1:57 ` paolo.carlini at oracle dot com
@ 2011-09-27  2:56 ` paolo at gcc dot gnu.org
  2011-09-27  4:15 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-09-27  2:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-09-27 02:39:42 UTC ---
Author: paolo
Date: Tue Sep 27 02:39:34 2011
New Revision: 179234

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179234
Log:
2011-09-26  Paolo Carlini  <paolo.carlini@oracle.com>

    PR libstdc++/50529
    * include/bits/vector.tcc (vector<>::erase(iterator, iterator)):
    Fix to do nothing if the range is empty.
    * include/bits/stl_bvector.h: Likewise.
    * include/bits/deque.tcc: Likewise.
    * include/debug/vector: Adjust.
    * include/debug/deque: Likewise.
    * testsuite/23_containers/vector/modifiers/erase/50529.cc: New.
    * testsuite/23_containers/deque/modifiers/erase/50529.cc: Likewise.
    * testsuite/23_containers/deque/modifiers/erase/3.cc: Adjust.

Added:
    trunk/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc
    trunk/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/50529.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/deque.tcc
    trunk/libstdc++-v3/include/bits/stl_bvector.h
    trunk/libstdc++-v3/include/bits/vector.tcc
    trunk/libstdc++-v3/include/debug/deque
    trunk/libstdc++-v3/include/debug/vector
    trunk/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/50529] [C++0x] std::vector::erase invokes undefined behavior with empty range
  2011-09-27  0:45 [Bug libstdc++/50529] New: std::vector::erase invokes undefined behavior with empty range delong.j at fb dot com
                   ` (2 preceding siblings ...)
  2011-09-27  2:56 ` paolo at gcc dot gnu.org
@ 2011-09-27  4:15 ` paolo.carlini at oracle dot com
  2011-09-27  7:56 ` delong.j at fb dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-27  4:15 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0
           Severity|major                       |normal

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-27 02:40:53 UTC ---
Done.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/50529] [C++0x] std::vector::erase invokes undefined behavior with empty range
  2011-09-27  0:45 [Bug libstdc++/50529] New: std::vector::erase invokes undefined behavior with empty range delong.j at fb dot com
                   ` (3 preceding siblings ...)
  2011-09-27  4:15 ` paolo.carlini at oracle dot com
@ 2011-09-27  7:56 ` delong.j at fb dot com
  2011-09-30 21:16 ` paolo at gcc dot gnu.org
  2011-09-30 23:36 ` paolo.carlini at oracle dot com
  6 siblings, 0 replies; 8+ messages in thread
From: delong.j at fb dot com @ 2011-09-27  7:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jordan DeLong <delong.j at fb dot com> 2011-09-27 02:56:14 UTC ---
Nice.  Thanks!


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/50529] [C++0x] std::vector::erase invokes undefined behavior with empty range
  2011-09-27  0:45 [Bug libstdc++/50529] New: std::vector::erase invokes undefined behavior with empty range delong.j at fb dot com
                   ` (4 preceding siblings ...)
  2011-09-27  7:56 ` delong.j at fb dot com
@ 2011-09-30 21:16 ` paolo at gcc dot gnu.org
  2011-09-30 23:36 ` paolo.carlini at oracle dot com
  6 siblings, 0 replies; 8+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-09-30 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-09-30 20:47:17 UTC ---
Author: paolo
Date: Fri Sep 30 20:47:12 2011
New Revision: 179403

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179403
Log:
2011-09-30  François Dumont  <fdumont@gcc.gnu.org>

    * include/debug/vector (vector<>::erase(iterator, iterator)): Check
    iterators equality using normal iterators.
    * include/debug/deque (deque<>::erase(iterator, iterator)): Likewise.

2011-09-30  Paolo Carlini  <paolo.carlini@oracle.com>

    PR libstdc++/50529
    * include/bits/vector.tcc (vector<>::erase(iterator, iterator)):
    Fix to do nothing if the range is empty.
    * include/bits/stl_bvector.h: Likewise.
    * include/bits/deque.tcc: Likewise.
    * include/debug/vector: Adjust.
    * include/debug/deque: Likewise.
    * testsuite/23_containers/vector/modifiers/erase/50529.cc: New.
    * testsuite/23_containers/deque/modifiers/erase/50529.cc: Likewise.
    * testsuite/23_containers/deque/modifiers/erase/3.cc: Adjust.

Added:
   
branches/gcc-4_6-branch/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/50529.cc
   
branches/gcc-4_6-branch/libstdc++-v3/testsuite/23_containers/vector/modifiers/erase/50529.cc
Modified:
    branches/gcc-4_6-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_6-branch/libstdc++-v3/include/bits/deque.tcc
    branches/gcc-4_6-branch/libstdc++-v3/include/bits/stl_bvector.h
    branches/gcc-4_6-branch/libstdc++-v3/include/bits/vector.tcc
    branches/gcc-4_6-branch/libstdc++-v3/include/debug/deque
    branches/gcc-4_6-branch/libstdc++-v3/include/debug/vector
   
branches/gcc-4_6-branch/libstdc++-v3/testsuite/23_containers/deque/modifiers/erase/3.cc


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/50529] [C++0x] std::vector::erase invokes undefined behavior with empty range
  2011-09-27  0:45 [Bug libstdc++/50529] New: std::vector::erase invokes undefined behavior with empty range delong.j at fb dot com
                   ` (5 preceding siblings ...)
  2011-09-30 21:16 ` paolo at gcc dot gnu.org
@ 2011-09-30 23:36 ` paolo.carlini at oracle dot com
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-30 23:36 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.0                       |4.6.2

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-30 20:48:32 UTC ---
Fixed in 4.6.2 too.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-09-30 20:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-27  0:45 [Bug libstdc++/50529] New: std::vector::erase invokes undefined behavior with empty range delong.j at fb dot com
2011-09-27  1:56 ` [Bug libstdc++/50529] [C++0x] " paolo.carlini at oracle dot com
2011-09-27  1:57 ` paolo.carlini at oracle dot com
2011-09-27  2:56 ` paolo at gcc dot gnu.org
2011-09-27  4:15 ` paolo.carlini at oracle dot com
2011-09-27  7:56 ` delong.j at fb dot com
2011-09-30 21:16 ` paolo at gcc dot gnu.org
2011-09-30 23:36 ` 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).