http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55916
Bug #: 55916 Summary: Alignment issues with real(16) on i686 Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: ja...@gcc.gnu.org The following testcase with -m32 -msse4 -g -O3 -fno-inline may segfault (depending on whether malloc returns just 8-byte or 16-byte aligned pointer). real(16), allocatable :: aaaa(:) real(16) :: x(10) integer :: i,n=10 allocate(aaaa(n)) do i = 1,n aaaa(i) = 8.0 enddo call foo (aaaa) deallocate(aaaa) contains subroutine foo (aaaa) real(16), allocatable :: aaaa(:) aaaa(1) = aaaa(1) + 1 end subroutine end The problem is that __float128 aka real(16) has alignment 128 bits, but on i686-linux malloc only guarantees 64 bit alignment (2 * sizeof (void *) byte alignment). As __float128 is outside of the scope of C/C++, this is not a bug on the C library side. Guess for real(16) allocatables or any allocatables that require alignment bigger than that of standard types Fortran should use posix_memalign (or perhaps some libgfortran wrapper) that will be passed not just the size to allocate, but also required alignment.