dart:ffi int8 etc truncate and sign extend vs exceptions #35787
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-ffi
type-design
What do we do with Dart ints which do not fit in the C++ type they are stored into.
And do we want the behavior to be consistent between
Pointer.store()
andPointer.asFunction()
?Throw exception
pro: safe
con: might be slower
con: Inconsistent with our handling of uint64, as there we interpret the bits as int64 instead of throwing exception. #35757
Truncate and sign extend
Trampoline truncates and sign extends argument passing -128 as 32/64 bits to C based on architecture
Various (or all) calling conventions do not truncate and sign extend values smaller than 32 bits, so it returns 254 (0xFE) which is sign extended by the trampoline as -2.
pro: fast
con: unexpected behavior
The text was updated successfully, but these errors were encountered: