https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119540
--- Comment #5 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #4)
> (In reply to anlauf from comment #3)
> > I might be missing to set some elem_len or span or ...
>
> Testcase:
Running the program (compiled with: -Og -g -fcheck=bounds) and setting
a breakpoint in __reduce_wrapper_c_op_test_reduce, one sees:
Breakpoint 1, test_reduce::__reduce_wrapper_c_op_test_reduce (a=..., b=...,
c=...,
_a=4435656, _b=4205221, _c=1) at reduce_c.f90:15
15 program test_reduce
(gdb) bt
#0 test_reduce::__reduce_wrapper_c_op_test_reduce (a=..., b=..., c=...,
_a=4435656,
_b=4205221, _c=1) at reduce_c.f90:15
#1 0x000000000041886e in _gfortran_reduce (ret=0x7fffffffcc20,
array=0x7fffffffcde0,
operation=0x402aa5 <test_reduce::__reduce_wrapper_c_op_test_reduce>,
dim=0x0, mask=0x0,
identity=0x0, ordered=0x0) at
../../../gcc-trunk/libgfortran/intrinsics/reduce.c:192
#2 0x0000000000418b37 in _gfortran_reduce_scalar_c (res=0x7fffffffd038,
res_strlen=8,
array=0x7fffffffcde0,
operation=0x402aa5 <test_reduce::__reduce_wrapper_c_op_test_reduce>,
dim=0x0, mask=0x0,
identity=0x0, ordered=0x0, array_strlen=8, identity_strlen=4204845)
at ../../../gcc-trunk/libgfortran/intrinsics/reduce.c:288
#3 0x00000000004029ba in test_reduce () at reduce_c.f90:20
The string lengths (_a, _b, _c) don't make any sense at all, because
operation (buffer_ptr, array_ptr, buffer);
apparently passes junk as arguments 4..6.