Re: [Boost-bugs] [Boost C++ Libraries] #12604: neither scoped_array nor checked_delete do check for nullptr

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12604: neither scoped_array nor checked_delete do check for nullptr
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-11-11 12:24:53


#12604: neither scoped_array nor checked_delete do check for nullptr
-------------------------------+-----------------------
  Reporter: steinbac@… | Owner: pdimov
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: smart_ptr
   Version: Boost 1.62.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+-----------------------

Comment (by anonymous):

 I am lost ... on every machine I tried, the attached code throws a
 segfault.

 {{{
 $ ./test
 Running 1 test case...

 *** No errors detected
 Segmentation fault (core dumped)
 }}}

 can you elaborate what you mean that nullptr is a valid argument to
 checked_delete? looking at the code, I see

 {{{
 template<class T> inline void checked_delete(T * x)
 {
     // intentionally complex - simplification causes regressions
     typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
     (void) sizeof(type_must_be_complete);
     delete x;
 }

 template<class T> inline void checked_array_delete(T * x)
 {
     typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
     (void) sizeof(type_must_be_complete);
     delete [] x;
 }
 }}}

 at no point, neither checked_delete nor checked_array_delete actually
 checks if (x != 0x0). Just wondering if this is expected from the client
 to checked delete? If yes, then scoped_array should check if the arguments
 to scoped_array::reset or scoped_array::swap are no 0x0.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12604#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC