Opened 17 years ago
Closed 17 years ago
#438 closed Bugs (Fixed)
shared_ptr/weak_ptr tests are not C++ spec compliant
Reported by: | nobody | Owned by: | Peter Dimov |
---|---|---|---|
Milestone: | Component: | smart_ptr | |
Version: | None | Severity: | |
Keywords: | Cc: |
Description
Please refer to the latest C++ spec (Second edition, 2003-04-01), section 12.8.15, "Copying class objects". Look at your source code in test/weak_ptr_test.cpp. 1. You cannot assume the reference count of the shared_ptr going into the copy_assignment function is one. The spec says that compilers are allowed to make an optimization to eliminate a copy, but not mandated to do so. This means that the effective reference count upon entry to the function may be two, not one. To correct your unit tests, forcibly create a local object that you pass by value to guarantee the reference count is two upon entry for all compilers. To respond to the following email address, remove all capital Z's. rZoZbZeZrZt.bZuZcZk@mathworks.com
Note:
See TracTickets
for help on using tickets.