[MacRuby] #1314: Objective-C methods with null-terminated arguments have a subtle issue
#1314: Objective-C methods with null-terminated arguments have a subtle issue ------------------------------------+--------------------------------------- Reporter: mrada@… | Owner: lsansonetti@… Type: defect | Status: new Priority: critical | Milestone: Component: MacRuby | Keywords: reduction ------------------------------------+--------------------------------------- Because nil is a legitimate object in Ruby, but not in objective-c, it can introduce subtle bugs: Example: {{{ framework 'Cocoa' array = NSArray.alloc.initWithObjects(nil,1,2,3) p array.size p array.inspect }}} Since reading the va_list stops when it finds the first nil, the array is never initialized with the numbers. I'm not sure how common this will be in practice though... -- Ticket URL: <http://www.macruby.org/trac/ticket/1314> MacRuby <http://macruby.org/>
#1314: Objective-C methods with null-terminated arguments have a subtle issue ------------------------------------+--------------------------------------- Reporter: mrada@… | Owner: lsansonetti@… Type: defect | Status: new Priority: critical | Milestone: Component: MacRuby | Keywords: reduction ------------------------------------+--------------------------------------- Comment(by watson1978@…): Objective-C also seems to create an empty array. {{{ #import <Cocoa/Cocoa.h> int main(void) { NSArray *ary = [[NSArray alloc] initWithObjects:nil,@"a",@"b",@"c"]; NSLog(@"%d", [ary count]); } }}} {{{ $ gcc test_array.m -framework Cocoa $ ./a.out 2011-06-30 23:20:45.852 a.out[27488:903] 0 }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1314#comment:1> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby