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

            Bug ID: 82968
           Summary: gfortran.dg/ieee/ieee_6.f90 fails at -O0
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ebotcazou at gcc dot gnu.org
  Target Milestone: ---
              Host: sparc64-linux
            Target: sparc64-linux
             Build: sparc64-linux

The test raises SIGBUS at run time:

Starting program: /1/ebotcazou/build/ieee_6 

Program received signal SIGBUS, Bus error.
__GI___fegetenv (envp=0x7fefffff14c) at ../sysdeps/sparc/fpu/fegetenv.c:25
25      ../sysdeps/sparc/fpu/fegetenv.c: No such file or directory.
(gdb) bt
#0  __GI___fegetenv (envp=0x7fefffff14c) at ../sysdeps/sparc/fpu/fegetenv.c:25
#1  0x0000000000100c68 in MAIN__ () at ieee_6.f90:23

because envp is not a multiple of 8.  On this platform, fenv_t is defined as:

/* Type representing floating-point environment.  */
typedef unsigned long int fenv_t;

so fegetenv expects an address multiple of 8 (the size of 'long').


The problematic Fortran type is apparently declared in ieee_exceptions.F90:

  type, public :: IEEE_STATUS_TYPE
    private
    character(len=GFC_FPE_STATE_BUFFER_SIZE) :: hidden
  end type

with the GFC_FPE_STATE_BUFFER_SIZE parameter coming from libgfortran.h:

/* Size of the buffer required to store FPU state for any target.
   In particular, this has to be larger than fenv_t on all glibc targets.
   Currently, the winner is x86_64 with 32 bytes.  */
#define GFC_FPE_STATE_BUFFER_SIZE 32

This obviously overlooks alignment constraints.

Reply via email to