public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/61086] New: ubsan detects undefined behaviour in the standard library
@ 2014-05-06 20:29 chris at detrino dot org
  2014-05-06 21:10 ` [Bug libstdc++/61086] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: chris at detrino dot org @ 2014-05-06 20:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61086
           Summary: ubsan detects undefined behaviour in the standard
                    library
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chris at detrino dot org

The following program compiled with clang++ -fsanitize=undefined reveals
undefined behavior.

Program:

#include <array>
#include <vector>

int main()
{
    std::vector<int> v;
    std::array<int, 2> array{{0, 1}};
    v.insert(v.end(), array.begin(), array.end());
}

Errors:

/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/stl_iterator.h:745:26:
runtime error: reference binding to null pointer of type 'typename
_PTraits::element_type' (aka 'int')
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/ptr_traits.h:169:31:
runtime error: reference binding to null pointer of type 'typename
__ptrtr_not_void<element_type>::__type' (aka 'int')
/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/move.h:136:31:
runtime error: reference binding to null pointer of type 'int'


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

* [Bug libstdc++/61086] ubsan detects undefined behaviour in the standard library
  2014-05-06 20:29 [Bug libstdc++/61086] New: ubsan detects undefined behaviour in the standard library chris at detrino dot org
@ 2014-05-06 21:10 ` redi at gcc dot gnu.org
  2014-05-07 11:49 ` [Bug libstdc++/61086] [4.9/4.10 Regression] " redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-06 21:10 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-05-06
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
     Ever confirmed|0                           |1


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

* [Bug libstdc++/61086] [4.9/4.10 Regression] ubsan detects undefined behaviour in the standard library
  2014-05-06 20:29 [Bug libstdc++/61086] New: ubsan detects undefined behaviour in the standard library chris at detrino dot org
  2014-05-06 21:10 ` [Bug libstdc++/61086] " redi at gcc dot gnu.org
@ 2014-05-07 11:49 ` redi at gcc dot gnu.org
  2014-05-07 14:44 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-07 11:49 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.8.2
   Target Milestone|---                         |4.9.1
            Summary|ubsan detects undefined     |[4.9/4.10 Regression] ubsan
                   |behaviour in the standard   |detects undefined behaviour
                   |library                     |in the standard library


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

* [Bug libstdc++/61086] [4.9/4.10 Regression] ubsan detects undefined behaviour in the standard library
  2014-05-06 20:29 [Bug libstdc++/61086] New: ubsan detects undefined behaviour in the standard library chris at detrino dot org
  2014-05-06 21:10 ` [Bug libstdc++/61086] " redi at gcc dot gnu.org
  2014-05-07 11:49 ` [Bug libstdc++/61086] [4.9/4.10 Regression] " redi at gcc dot gnu.org
@ 2014-05-07 14:44 ` redi at gcc dot gnu.org
  2014-05-07 15:05 ` redi at gcc dot gnu.org
  2014-05-07 15:07 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-07 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Wed May  7 14:43:22 2014
New Revision: 210162

URL: http://gcc.gnu.org/viewcvs?rev=210162&root=gcc&view=rev
Log:
    PR libstdc++/61086
    * include/bits/stl_iterator.h (__normal_iterator::_M_const_cast):
    Remove.
    * include/bits/stl_vector.h (vector::insert, vector::erase): Use
    arithmetic to obtain a mutable iterator from const_iterator.
    * include/bits/vector.tcc (vector::insert): Likewise.
    * include/debug/vector (vector::erase): Likewise.
    * testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
    Adjust dg-error line number.
    * testsuite/23_containers/vector/requirements/dr438/
    constructor_1_neg.cc: Likewise.
    * testsuite/23_containers/vector/requirements/dr438/
    constructor_2_neg.cc: Likewise.
    * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
    Likewise.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/stl_iterator.h
    trunk/libstdc++-v3/include/bits/stl_vector.h
    trunk/libstdc++-v3/include/bits/vector.tcc
    trunk/libstdc++-v3/include/debug/vector
   
trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
   
trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
   
trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
   
trunk/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc


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

* [Bug libstdc++/61086] [4.9/4.10 Regression] ubsan detects undefined behaviour in the standard library
  2014-05-06 20:29 [Bug libstdc++/61086] New: ubsan detects undefined behaviour in the standard library chris at detrino dot org
                   ` (2 preceding siblings ...)
  2014-05-07 14:44 ` redi at gcc dot gnu.org
@ 2014-05-07 15:05 ` redi at gcc dot gnu.org
  2014-05-07 15:07 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-07 15:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Wed May  7 15:05:22 2014
New Revision: 210163

URL: http://gcc.gnu.org/viewcvs?rev=210163&root=gcc&view=rev
Log:
    PR libstdc++/61086
    * include/bits/stl_iterator.h (__normal_iterator::_M_const_cast):
    Remove.
    * include/bits/stl_vector.h (vector::insert, vector::erase): Use
    arithmetic to obtain a mutable iterator from const_iterator.
    * include/bits/vector.tcc (vector::insert): Likewise.
    * include/debug/vector (vector::erase): Likewise.
    * testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
    Adjust dg-error line number.
    * testsuite/23_containers/vector/requirements/dr438/
    constructor_1_neg.cc: Likewise.
    * testsuite/23_containers/vector/requirements/dr438/
    constructor_2_neg.cc: Likewise.
    * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
    Likewise.

Modified:
    branches/gcc-4_9-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_9-branch/libstdc++-v3/include/bits/stl_iterator.h
    branches/gcc-4_9-branch/libstdc++-v3/include/bits/stl_vector.h
    branches/gcc-4_9-branch/libstdc++-v3/include/bits/vector.tcc
    branches/gcc-4_9-branch/libstdc++-v3/include/debug/vector
   
branches/gcc-4_9-branch/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
   
branches/gcc-4_9-branch/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
   
branches/gcc-4_9-branch/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
   
branches/gcc-4_9-branch/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc


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

* [Bug libstdc++/61086] [4.9/4.10 Regression] ubsan detects undefined behaviour in the standard library
  2014-05-06 20:29 [Bug libstdc++/61086] New: ubsan detects undefined behaviour in the standard library chris at detrino dot org
                   ` (3 preceding siblings ...)
  2014-05-07 15:05 ` redi at gcc dot gnu.org
@ 2014-05-07 15:07 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-07 15:07 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 4.9.1, thanks for the report.


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

end of thread, other threads:[~2014-05-07 15:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-06 20:29 [Bug libstdc++/61086] New: ubsan detects undefined behaviour in the standard library chris at detrino dot org
2014-05-06 21:10 ` [Bug libstdc++/61086] " redi at gcc dot gnu.org
2014-05-07 11:49 ` [Bug libstdc++/61086] [4.9/4.10 Regression] " redi at gcc dot gnu.org
2014-05-07 14:44 ` redi at gcc dot gnu.org
2014-05-07 15:05 ` redi at gcc dot gnu.org
2014-05-07 15:07 ` redi at gcc dot gnu.org

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).