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

--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Segher Boessenkool from comment #5)
> No, doesn't ring bells.  But I have some more input:
> 
> I couldn't get it to fail on powerpc64-linux.
> It fails on powerpc64le-linux only if the second file is compiled with -O0.

Not for me:

tkoenig@gcc2-power8 ~]$ ~/bin/gfortran -static-libgfortran main.f
doesntwork_p8.f 
[tkoenig@gcc2-power8 ~]$ ./a.out
           1           2           3           4           5           0
 �
 foo                 
[tkoenig@gcc2-power8 ~]$ valgrind ./a.out
==145922== Memcheck, a memory error detector
==145922== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==145922== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==145922== Command: ./a.out
==145922== 
==145922== Conditional jump or move depends on uninitialised value(s)
==145922==    at 0x10013EF8: write_decimal.constprop.10 (write.c:808)
==145922==    by 0x100143F7: write_integer (write.c:1351)
==145922==    by 0x1001584F: list_formatted_write_scalar (write.c:1865)
==145922==    by 0x1001664B: _gfortrani_list_formatted_write (write.c:1943)
==145922==    by 0x10005A47: transfer_integer (transfer.c:2294)
==145922==    by 0x10005A47: _gfortran_transfer_integer_write (transfer.c:2300)
==145922==    by 0x10002563: doesntwork_p8_ (in /home/tkoenig/a.out)
==145922==    by 0x10002443: MAIN__ (in /home/tkoenig/a.out)
==145922==    by 0x100021E3: main (in /home/tkoenig/a.out)
==145922== 
==145922== Conditional jump or move depends on uninitialised value(s)
==145922==    at 0x100100BC: extract_int (write.c:556)
==145922==    by 0x10013F0B: write_decimal.constprop.10 (write.c:810)
==145922==    by 0x1001584F: list_formatted_write_scalar (write.c:1865)
==145922==    by 0x1001664B: _gfortrani_list_formatted_write (write.c:1943)
==145922==    by 0x10005A47: transfer_integer (transfer.c:2294)
==145922==    by 0x10005A47: _gfortran_transfer_integer_write (transfer.c:2300)
==145922==    by 0x100025C7: doesntwork_p8_ (in /home/tkoenig/a.out)
==145922==    by 0x10002443: MAIN__ (in /home/tkoenig/a.out)
==145922==    by 0x100021E3: main (in /home/tkoenig/a.out)
==145922== 
           1           2           3           4           5           0
 o
 foo                 

Also, you have to add the six arguments; it works with five.

Next data point: On a POWER9, it also fails.

There is one other thing: With gcc9 on x86_64, one gets

gfortran -flto main.f doesnwork_p8.f
main.f:7: warning: type of 'doesntwork_p8' does not match original declaration
[-Wlto-type-mismatch]
7 |         res = doesntwork_p8(c,1,2,3,4,5,6)
  | 
doesnwork_p8.f:1: note: type mismatch in parameter 3
1 |       function doesntwork_p8(c,a1,a2,a3,a4,a5,a6)
  | 
doesnwork_p8.f:1: note: 'doesntwork_p8' was previously declared here

So, probably something wrong with our decls.

Reply via email to