Opened 14 years ago

Closed 14 years ago

#2554 closed Bugs (invalid)

shared_ptr initialized with NULL returns use_count() == 1

Reported by: anonymous Owned by: Peter Dimov
Milestone: Boost 1.38.0 Component: smart_ptr
Version: Boost 1.37.0 Severity: Problem
Keywords: Cc:

Description

After creating shared_ptr with NULL initial value, it returns use_count() == 1:

shared_ptr<int> p(NULL); cout << p.use_count() << endl;

Change History (3)

comment:1 by Steven Watanabe, 14 years ago

Component: Nonesmart_ptr
Owner: set to Peter Dimov

comment:2 by Frank Mori Hess, 14 years ago

This isn't a bug. You've created a "null" shared_ptr, which is different from an "empty" shared_ptr. Only an "empty" shared_ptr has a use_count of zero.

comment:3 by Peter Dimov, 14 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.