public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55916] New: Alignment issues with real(16) on i686
@ 2013-01-09 11:47 jakub at gcc dot gnu.org
  2013-01-09 11:55 ` [Bug fortran/55916] " rguenth at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-01-09 11:47 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: jakub@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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-02-08 23:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-09 11:47 [Bug fortran/55916] New: Alignment issues with real(16) on i686 jakub at gcc dot gnu.org
2013-01-09 11:55 ` [Bug fortran/55916] " rguenth at gcc dot gnu.org
2013-01-09 12:26 ` glisse at gcc dot gnu.org
2013-01-09 13:31 ` rguenth at gcc dot gnu.org
2013-01-09 13:38 ` rguenth at gcc dot gnu.org
2013-01-09 16:10 ` pinskia at gcc dot gnu.org
2013-01-09 20:57 ` joseph at codesourcery dot com
2014-02-07  8:03 ` ubizjak at gmail dot com
2014-02-08 15:04 ` jouko.orava at iki dot fi
2014-02-08 15:11 ` dominiq at lps dot ens.fr
2014-02-08 18:25 ` jouko.orava at iki dot fi
2014-02-08 23:51 ` jouko.orava at iki dot fi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).