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 , 14 years ago
| Component: | None → smart_ptr |
|---|---|
| Owner: | set to |
comment:2 by , 14 years ago
comment:3 by , 14 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.

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.