https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87851
--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Here is the result of running f951 with -O under the debugger
and breaking on optimize_expr:
Breakpoint 1, optimize_expr (e=0x2688cf0, walk_subtrees=0x7fffffffd81c,
data=0x0) at ../../trunk/gcc/fortran/frontend-passes.c:340
(gdb) call gfc_debug_expr(*e)
__len_trim1[[((main:c) ((arg not-present)))]]
(gdb) p (*e)->ts
$2 = {type = BT_INTEGER, kind = 4, u = {derived = 0x0, cl = 0x0, pad = 0},
interface = 0x0, is_c_interop = 0, is_iso_c = 0, f90_type = BT_UNKNOWN,
deferred = false, interop_kind = 0x0}
This is wrong, the kind should be 8.
Setting (*e)->ts.kind to 8 and letting the test run to completion,
and comparing the different assemblies generated (len_trim_8.s
is the one with the kind set to 8)
--- len_trim_8.s 2019-01-07 21:13:33.494640974 +0100
+++ len_trim.s 2019-01-07 21:13:41.526726760 +0100
@@ -10,20 +10,20 @@
.cfi_startproc
subq $552, %rsp
.cfi_def_cfa_offset 560
- movw $8289, 533(%rsp)
- movb $32, 535(%rsp)
+ movw $8289, 537(%rsp)
+ movb $32, 539(%rsp)
movq $.LC0, 8(%rsp)
movl $4, 16(%rsp)
movl $128, (%rsp)
movl $6, 4(%rsp)
movq %rsp, %rdi
call _gfortran_st_write
- leaq 533(%rsp), %rsi
+ leaq 537(%rsp), %rsi
movl $3, %edi
call _gfortran_string_len_trim
- movq %rax, 536(%rsp)
- movl $8, %edx
- leaq 536(%rsp), %rsi
+ movl %eax, 540(%rsp)
+ movl $4, %edx
+ leaq 540(%rsp), %rsi
movq %rsp, %rdi
call _gfortran_transfer_integer_write
movq %rsp, %rdi
If I read this correctly, the function is called with
four-byte arguments, but it should be eight.