This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/206] malloc does not align memory correctly for sse capable systems
- From: "bangerth at dealii dot org" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 6 Jun 2004 18:27:36 -0000
- Subject: [Bug libc/206] malloc does not align memory correctly for sse capable systems
- References: <20040605142238.206.ma1flfs@bath.ac.uk>
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
------- Additional Comments From bangerth at dealii dot org 2004-06-06 18:27 -------
For a history of this bug: this used to be PR 15795 in gcc's bugzilla, see
http://gcc.gnu.org/ml/gcc-bugs/2004-06/msg00552.html
As for the implications: the C standard says that the pointer returned by
malloc needs to be sufficiently aligned for _all_ data types. This alignment
is specified in the ABI of a system, and for systems that allow the creation
of SSE data types, this means that malloc needs to return 16-byte aligned
pointers. I know that this is unfortunate, but there really is no other
way of fixing malloc; for example, consider a program that uses
std::vector<__m128> x(13);
Here, std::vector has to call 'operator new' which itself has to call
malloc(). If malloc doesn't return sufficiently aligned pointers, the
resulting std::vector is unusable. Note that here the memory allocation
has to happen inside gcc's libstdc++, and is this out of user's control
-- so one can't use posix_memalign here.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
http://sources.redhat.com/bugzilla/show_bug.cgi?id=206
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.