NSValue instance coding raises exception when the value contains struct variable

Originator:Tomas.Kolar
Number:rdar://8631663 Date Originated:04-Nov-2010 07:49 PM
Status:Duplicate Resolved:same as #7619392
Product:Mac OS X Product Version:10.5 and 10.6
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
Attempt to encode instance of NSValue always raises an exception when that instance contains value of type struct and when coder is instance of NSKeyedArchiver class. The NSValue instance has been created with value:withObjCType: method and has been encoded with encodeObject:forKey: method. The exception is of type NSInvalidArgumentException and is raised due to "-[NSKeyedArchiver encodeValueOfObjCType:at:]: this archiver cannot encode structs", but that method was not use implicitly.

Steps to Reproduce:
1) Create variable that is of type struct.
2) Create instance of NSValue class using value:withObjCType: method.
3) Encode this object using encodeObject:forKey: method of NSKeyedArchiver instance.

Expected Results:
NSKeyedArchiver should encode instance of NSValue class that contains struct variable as same as any other object.

Actual Results:
NSInvalidArgumentException is raised.

Regression:
Tested on 10.6.4/Mac Pro (1.1) 2x2.66 GHz and on 10.5.8/PowerBook 12" 1.5 GHz.

Notes:
Command line utility crashes and provides the crash log, that is attached. Also file with basic sample code is attached.

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!