C++ destructors for obj-c++ ivars are not called when NSZombie is enabled
Originator: | ciawal | ||
Number: | rdar://6411137 | Date Originated: | 02-Dec-2008 02:20 AM |
Status: | Open | Resolved: | |
Product: | Mac OS X | Product Version: | |
Classification: | Reproducible: |
02-Dec-2008 02:20 AM Ciaran Walsh: Summary: When compiled with -fobjc-call-cxx-cdtors an Obj-C++ class with C++ objects as instance data should call the destructors for those objects after deallocation. The destructors are not called when NSZombie is enabled. Steps to Reproduce: Attached file includes an Objective-C++ class with a C++ object as an instance variable, it should be compiled using -fobjc-call-cxx-cdtors Expected Result: When the product is run, the C++ object should be destructed with the Objective-C++ object, even when NSZombieEnabled is set to YES Actual Result: When NSZombieEnabled is YES the C++ object is not destructed. Sample code: #import <Cocoa/Cocoa.h> #import <iostream> struct foo_t { foo_t () { } ~foo_t () { std::cout << "~foo_t\n"; } }; @interface Test : NSObject { foo_t foo; } @end @implementation Test - (void)dealloc { std::cout << "dealloc\n"; [super dealloc]; } @end int main () { [[Test new] release]; }
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
In a certain piece of software...
int main () { std::cout << getenv("NSZombieEnabled") << std::endl; [[Test new] release]; }
Running… YES dealloc ~foo_t