This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/13864] stl_hastable.h Line 527


------- Additional Comments From greg dot bertin at solacesystems dot com  2004-01-26 14:26 -------
Subject: RE:  stl_hastable.h Line 527

Ignore this last one ... my idiocy ... copy constructors initialize
uninitialized memory ... one of these days I will learn C++ :-)

> -----Original Message-----
> From: Greg Bertin [mailto:greg.bertin@solacesystems.com]
> Sent: Monday, January 26, 2004 9:23 AM
> To: 'gcc-bugzilla@gcc.gnu.org'
> Subject: RE: [Bug libstdc++/13864] stl_hastable.h Line 527
> 
> Hi pinskia ...
> 
> __n is initialized but the memory being pointed at by __n is not. It
is
> memory allocated via _M_get_node():
> 
>   _Node* _M_get_node() { return _M_node_allocator.allocate(1); }
> 
> Allocators return uninitialized memory blocks. This is a problem
because
> _Construct():
> 
>   template <class _T1, class _T2>
>     inline void
>     _Construct(_T1* __p, const _T2& __value)
>     { new (static_cast<void*>(__p)) _T1(__value); }
> 
> assumes that __p points to a properly initialized T1 object since it
> invokes T1's copy constructor. T1's copy constructor will assume that
T1's
> members (e.g. pointer members that are not NULL and thus need to be
> deallocate()'d/delete()'d/free()'d/whatever) have been properly
> initialized. The other uses of _Construct() in the standard STL that I
> checked all pass a properly initialized __p to _Construct and thus
behave
> correctly.
> 
> 
> Thanks for looking at this!!
> 
> > -----Original Message-----
> > From: pinskia at gcc dot gnu dot org
[mailto:gcc-bugzilla@gcc.gnu.org]
> > Sent: Monday, January 26, 2004 8:24 AM
> > To: greg.bertin@solacesystems.com
> > Subject: [Bug libstdc++/13864] stl_hastable.h Line 527
> >
> >
> > ------- Additional Comments From pinskia at gcc dot gnu dot org
2004-
> 01-
> > 26 13:23 -------
> > Here is the full source, n __n is initialized:
> >   _Node* _M_new_node(const value_type& __obj)
> >   {
> >     _Node* __n = _M_get_node();
> >     __n->_M_next = 0;
> >     try {
> >       _Construct(&__n->_M_val, __obj);
> >       return __n;
> >     }
> >     catch(...)
> >       {
> >         _M_put_node(__n);
> >         __throw_exception_again;
> >       }
> >   }
> >
> > --
> >            What    |Removed                     |Added
> >
------------------------------------------------------------------------
> --
> > --
> >              Status|UNCONFIRMED                 |RESOLVED
> >          Resolution|                            |INVALID
> >
> >
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13864
> >
> > ------- You are receiving this mail because: -------
> > You reported the bug, or are watching the reporter.




-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]