{"record":{"id":"248af369d00f25ac","repo":"PyO3/pyo3","slug":"size-t-should-fit-the-flag-bits","errorCode":null,"errorMessage":"size_t should fit the flag bits","messagePattern":"size_t should fit the flag bits","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pyo3-ffi/src/abstract_.rs","lineNumber":90,"sourceCode":"    ) -> *mut PyObject;\n\n    #[cfg(all(Py_3_12, Py_LIMITED_API))] // is an inline function in cpython/abstract.rs on version-specific ABI\n    #[cfg_attr(PyPy, link_name = \"PyPyVectorcall_NARGS\")]\n    pub fn PyVectorcall_NARGS(nargsf: size_t) -> Py_ssize_t;\n\n    #[cfg_attr(not(any(Py_3_12, PyPy)), link_name = \"_PyVectorcall_Call\")] // symbol made public in 3.12\n    #[cfg_attr(PyPy, link_name = \"PyPyVectorcall_Call\")]\n    pub fn PyVectorcall_Call(\n        callable: *mut PyObject,\n        tuple: *mut PyObject,\n        dict: *mut PyObject,\n    ) -> *mut PyObject;\n}\n\n#[cfg(any(Py_3_12, not(Py_LIMITED_API)))]\npub const PY_VECTORCALL_ARGUMENTS_OFFSET: size_t = (1 as size_t)\n    .checked_shl((8 * core::mem::size_of::<size_t>() - 1) as u32)\n    .expect(\"size_t should fit the flag bits\");\n\nextern_libpython! {\n    #[cfg_attr(PyPy, link_name = \"PyPyObject_Vectorcall\")]\n    #[cfg(any(Py_3_12, all(Py_3_11, not(Py_LIMITED_API))))]\n    pub fn PyObject_Vectorcall(\n        callable: *mut PyObject,\n        args: *const *mut PyObject,\n        nargsf: size_t,\n        kwnames: *mut PyObject,\n    ) -> *mut PyObject;\n\n    #[cfg(any(Py_3_12, not(any(Py_LIMITED_API, PyPy))))]\n    pub fn PyObject_VectorcallMethod(\n        name: *mut PyObject,\n        args: *const *mut PyObject,\n        nargsf: size_t,\n        kwnames: *mut PyObject,\n    ) -> *mut PyObject;","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/PyO3/pyo3/blob/ac9b6899d348be4d54614d060dea53a645a12e36/pyo3-ffi/src/abstract_.rs#L72-L108","documentation":"pyo3-ffi computes PY_VECTORCALL_ARGUMENTS_OFFSET as 1 shifted left by (bits of size_t - 1). checked_shl returns None if the shift amount is invalid and the code panics with 'size_t should fit the flag bits'. On any real target where size_t is 8/16/32/64 bits this cannot trigger; it's a compile-time-time guard that the platform's size_t supports the bit math.","triggerScenarios":"Compilation for a target whose size_t is unusually small or where core::mem::size_of::<size_t>()*8 exceeds the valid shift range for u32 checked_shl (>= 32... actually a shift >= width of size_t). Essentially only exotic/nonstandard targets.","commonSituations":"Cross-compiling pyo3 to an unsupported embedded target with an unusual size_t width.","solutions":["Compile for a supported platform where size_t is a standard width","Do not use pyo3 on targets with pathological size_t definitions","File an issue with pyo3 if your legitimate target hits this"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Only build pyo3-ffi on targets with standard size_t\ntarget_pointer_width in [16, 32, 64] // verified via cfg in build script","tryCatchPattern":null,"preventionTips":["Stick to supported target triples","Validate cross-compile targets early in CI","Keep toolchain/target specs standard"],"tags":["rust","pyo3-ffi","const-panic","platform"],"backgroundTag":"const-assertion-panic","analyzedSha":"ac9b6899d348be4d54614d060dea53a645a12e36","analyzedAt":"2026-09-05T09:20:35.319Z","contentChangedAt":"2026-09-05T09:20:35.319Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}