Issue #180 closed
mike fc
created an issue

Allow CFFI allocated types e.g. cffi.new("uint8_t *", 0) to overflow like C.

Currently

>> a = ffi.new("uint8_t *", 0)
>> a[0] += 300

OverflowError: integer 300 does not fit 'uint8_t'

But I don't really care that it doesn't fit. Just do what the underlying C would do. e.g.

>> ffi.cdef("int crap(void);")
>> C = ffi.verify("int crap(void) {uint8_t i=0; i+=300; return i;}")
>> C.crap()

44

I know it's probably dangerous, but I'm messing with C so I'm already living dangerously.

I look forward to finding out just how this is a terrible idea :)

Comments (2)

  1. Log in to comment