Ugly bug in Foundation, beware!
Ugly bug in Foundation, beware!
- Subject: Ugly bug in Foundation, beware!
- From: Ondra Cada <email@hidden>
- Date: Thu, 3 Jun 2004 15:05:24 +0200
Hi all,
just bumped into this: mutable arrays do *NOT* deep copy upon receiving
-copy
#import <Foundation/Foundation.h>
int main() {
[NSAutoreleasePool new];
id a=[NSMutableArray arrayWithObject:[NSMutableArray array]],b=[a copy];
NSLog(@"contents: %x %x",[a lastObject],[b lastObject]);
// this is why it is very very bad
[[a lastObject] addObject:@"this is WAY wrong if seen in b!!!"];
NSLog(@"changed a, my private b is %@",[b description]);
return 0;
}
Didn't check mutable sets, dicts, et cetera, but i'd bet they share
this howler :(((((
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
- Follow-Ups:
- Re: Ugly bug in Foundation, beware!
- From: Finlay Dobbie <email@hidden>
- Re: Ugly bug in Foundation, beware!
- From: Chris Hanson <email@hidden>
- Re: Ugly bug in Foundation, beware!
- From: Andy Lee <email@hidden>
- Re: Ugly bug in Foundation, beware!
- From: Marco Scheurer <email@hidden>
- Re: Ugly bug in Foundation, beware!
- From: Brent Gulanowski <email@hidden>
- Re: Ugly bug in Foundation, beware!
- From: Nicko van Someren <email@hidden>
- Is that really a bug at all? (was: Re: Ugly bug in Foundation, beware!)
- From: Alastair Houghton <email@hidden>
- Re: Ugly bug in Foundation, beware!
- From: Zach Wily <email@hidden>
- Re: Ugly bug in Foundation, beware!
- From: Glenn Andreas <email@hidden>
- Re: Ugly bug in Foundation, beware!
- From: Clark Cox <email@hidden>