New submission from Petr Viktorin <encu...@gmail.com>:

malloc() returns memory that's "suitably aligned for any built-in type".
All of Python's allocation functions should do the same. 

In bpo-27987 (PR-12850, PR-13336), the alignment was raised* to 16 bytes and 
`long double`. This is OK for current architectures, so there is no practical 
issue right now.

But, C11 defines a [max_align_t] type which sounds like the *correct* thing to 
use for determining pymalloc/PyGC_Head alignment.
At least we should assert that obmalloc's ALIGNMENT is a multiple of 
`alignof(max_align_t)`, and use max_align_t rather than `long double` in 
PyGC_Head.



See also this python-cffi issue: 
https://foss.heptapod.net/pypy/cffi/-/issues/531#note_181779

[max_align_t]: https://en.cppreference.com/w/c/types/max_align_t

* (on 64-bit arches)

----------
components: C API
messages: 416421
nosy: methane, petr.viktorin, pitrou, vstinner
priority: normal
severity: normal
status: open
title: pymalloc should align to max_align_t

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue47179>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to