You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
c_import: should C function-pointer fields import as nullable? (D101 zero-validity) #2215
D101 makes T.zeroed() available only on zero-valid C records. c_import maps a C function-pointer field to a non-null extern "C" fn (zlib z_stream.zalloc, stdlib sigevent.sigev_notify_function), so those records have no zeroed(), and an in-place facade over real zlib's z_stream would need a preinit. In C such a field is routinely NULL (zlib's Z_NULL zalloc means "use the default"), so non-null is arguably the wrong model. Importing them as nullable would make these records zero-valid. This is a C-interop mapping question for Eric.
Ruled D102 and implemented by #2218 (73c7cf8): c_import maps function pointers by direction — field, element, pointee, return and global are Option; typedef and a c_import prototype's parameter stay non-null; a facade widens a parameter with nullable param N; a migrated definition's parameter keeps C's nullability. zlib's z_stream and stdlib's sigevent are zero-valid under D101 now.
Activity
D101: T.zeroed() is safe on zero-valid C records; the facade's in-pla…
D100: a field without pub is private to its package (#2209) (#2212)
D102: extern "C" fn is non-null; nullable C function pointers are a p…
D102: non-null extern fn; nullable C function pointers as pointer-siz…
ehartford commentedon Oct 6, 2026
Ruled D102 and implemented by #2218 (73c7cf8): c_import maps function pointers by direction — field, element, pointee, return and global are
Option; typedef and a c_import prototype's parameter stay non-null; a facade widens a parameter withnullable param N; a migrated definition's parameter keeps C's nullability. zlib's z_stream and stdlib's sigevent are zero-valid under D101 now.