https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87689
Alan Modra <amodra at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amodra at gmail dot com --- Comment #9 from Alan Modra <amodra at gmail dot com> --- The call in main is wrong. From comment #3 > Tree dump looks reasonable with 8.1: > > static integer(kind=4) C.2183 = 1; > static integer(kind=4) C.2184 = 2; > static integer(kind=4) C.2185 = 3; > static integer(kind=4) C.2186 = 4; > static integer(kind=4) C.2187 = 5; > static integer(kind=4) C.2188 = 6; > character(kind=1) str.0[20]; > > doesntwork_p8 ((character(kind=1)[1:20] *) &str.0, 20, &c, &C.2183, > &C.2184, &C.2185, &C.2186, &C.2187, &C.2188, 1); Looking at the assembly, I see r3 is &str.0, r4 is 20, r5 is &c, and so on up to r10 which is &C.2187. That's all good. The next arg, &C.2188 is stored on the stack at 32(1). That's wrong. It should be 96(1), ie. leaving 64 bytes of parameter save area. Similarly for the final "1", which is stored at 40(1) instead of 104(1). Debugging a little, it seems that the cause is that the fndecl found in expand_call is missing args. These lines in expand_call #ifdef REG_PARM_STACK_SPACE reg_parm_stack_space = REG_PARM_STACK_SPACE (!fndecl ? fntype : fndecl); #endif then calculate 0 for reg_parm_stack_space, which is correct for the given bogus fndecl. <function_decl 0x7ffff68bd500 doesntwork_p8 type <function_type 0x7ffff68c1a80 type <void_type 0x7ffff67b1f18 void VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff67b1f18 pointer_to_this <pointer_type 0x7ffff67ba000>> SI size <integer_cst 0x7ffff67b60d8 constant 32> unit-size <integer_cst 0x7ffff67b60f0 constant 4> align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff68c19d8 attributes <tree_list 0x7ffff68bcd70 purpose <identifier_node 0x7ffff6813a28 fn spec> value <tree_list 0x7ffff68bcd48 value <string_cst 0x7ffff68b0bd0 constant ".wR">>> arg-types <tree_list 0x7ffff68bcd20 value <reference_type 0x7ffff68c1930> chain <tree_list 0x7ffff68bccf8 value <integer_type 0x7ffff67b1738 integer(kind=8)> chain <tree_list 0x7ffff67b2168 value <void_type 0x7ffff67b1f18 void>>>> pointer_to_this <pointer_type 0x7ffff68c1b28>> addressable used public external SI /home/alan/src/tmp/pr87689_main.f:7:0 align:32 warn_if_not_align:0 context <translation_unit_decl 0x7ffff68be000 /home/alan/src/tmp/pr87689_main.f> chain <function_decl 0x7ffff68bd600 main>>