https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77330

--- Comment #9 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to jos...@codesourcery.com from comment #8)
> 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 

Yes, but isn't that an ABI decision?

What if the ABI says __float128 has to be 8-byte-aligned on this machine,
because the memory returned from malloc is per definition usable for
anything that contains __float128?

Like this:

Index: gcc/tree.c
===================================================================
--- gcc/tree.c  (revision 239659)
+++ gcc/tree.c  (working copy)
@@ -10349,6 +10349,7 @@ build_common_tree_nodes (bool signed_char)
       SET_TYPE_MODE (FLOATN_NX_TYPE_NODE (i), mode);
     }

+  SET_TYPE_ALIGN (float128_type_node, MALLOC_ABI_ALIGNMENT);
   float_ptr_type_node = build_pointer_type (float_type_node);
   double_ptr_type_node = build_pointer_type (double_type_node);
   long_double_ptr_type_node = build_pointer_type (long_double_type_node);

Reply via email to