This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/77330] __float128 segfaults on 32-bit x86 due to 8-byte malloc alignment
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 23 Aug 2016 20:21:20 +0000
- Subject: [Bug target/77330] __float128 segfaults on 32-bit x86 due to 8-byte malloc alignment
- Auto-submitted: auto-generated
- References: <bug-77330-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77330
--- Comment #8 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Tue, 23 Aug 2016, bernd.edlinger at hotmail dot de wrote:
> gcc assumes that malloc, calloc, realloc, strdup, strndup
> and anything with the __attribute__((__malloc__))
> returns a pointer that is aligned to MALLOC_ABI_ALIGNMENT bits.
That it makes this more conservative assumption for some optimization
purposes is separate from the assumption that if you dereference a pointer
to a type, that pointer, however you got it, meets the alignment
requirements for the type. __float128 is 16-byte-aligned, so GCC assumes
any dereferenced pointer to it is also 16-byte-aligned, and it's the
user's job to meet that requirement (by not using malloc for that
allocation if it doesn't return sufficiently aligned memory). There is no
difference between __float128 and __m512 in this regard: a malloc that
doesn't return suitably aligned memory isn't suitable for allocating
storage for such objects, and if you use malloc to do so then GCC will
assume that, at least for that particular allocation, the return value is
suitably aligned.