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

--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The following test (reduced from gfortran.dg/pr46588.f90)

function aufun(pm)
   character(len = *) pm
   character(len = *) aufun
   print *, ">", pm, "<"
   aufun = 'Oh' // trim(pm)
end function aufun

program ds
   implicit none
   character(len = 4) :: ins = ' no!'
   character(len = 20) st, aufun 
   logical(4) :: tst
   print *, ">", ins, "<"
   st = aufun(ins)
   print *, ">", st, "<"
end

gives

 > no!<

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

at run time when compiled with -m32 -fdefault-integer-8.

I don't see any difference when comparing the outputs of -fdump-tree-original
with -m32 or -m32 -fdefault-integer-8, but I see the following difference in
the assembly files

--- pr46588_db.s        2018-03-05 12:50:58.000000000 +0100
+++ pr46588_db_m32.s    2018-03-05 12:50:41.000000000 +0100
@@ -3,8 +3,7 @@

 # GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 # options passed:  pr46588_db.f90 -fPIC -m32 -mmacosx-version-min=10.13.0
-# -mtune=corei7 -march=corei7 -fdefault-integer-8 -fdump-tree-original
-# -fverbose-asm
+# -mtune=corei7 -march=corei7 -fdump-tree-original -fverbose-asm
 # -fintrinsic-modules-path
/opt/gcc/gcc8w/lib/gcc/x86_64-apple-darwin17.4.0/8.0.1/i386/finclude
 # options enabled:  -Wnonportable-cfstrings -fPIC
 # -faggressive-loop-optimizations -fasynchronous-unwind-tables
@@ -255,16 +254,14 @@ L2$pb:
        call    __gfortran_st_write_done        #
        addl    $16, %esp       #,
 # pr46588_db.f90:14:    st = aufun(ins)
-       subl    $12, %esp       #,
        pushl   $4      #
        leal    _ins.3702-L2$pb(%ebx), %eax     #, tmp97
        pushl   %eax    # tmp97
-       pushl   $0      #
        pushl   $20     #
        leal    -48(%ebp), %eax #, tmp98
        pushl   %eax    # tmp98
        call    _aufun_ #
-       addl    $32, %esp       #,
+       addl    $16, %esp       #,
        movl    -48(%ebp), %eax # MEM[(c_char * {ref-all})&str.5], tmp99
        movl    %eax, -28(%ebp) # tmp99, MEM[(c_char * {ref-all})&st]
        movl    -44(%ebp), %eax # MEM[(c_char * {ref-all})&str.5], tmp100

Reply via email to