https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81062
Bug ID: 81062 Summary: Allocate on assignment with reshape(eoshift(...)) Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: tkoenig at gcc dot gnu.org Target Milestone: --- program main real, dimension(:), allocatable :: r real, dimension(3,3) :: a call random_number(a) r = reshape(eoshift(a,1),shape(r)) print *,size(r) print *,r end program main $ gfortran resh.f90 $ $ ./a.out 0 $ valgrind ./a.out ==17442== Memcheck, a memory error detector ==17442== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==17442== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info ==17442== Command: ./a.out ==17442== ==17442== Conditional jump or move depends on uninitialised value(s) ==17442== at 0x4F96C30: _gfortran_reshape_r4 (reshape_r4.c:93) ==17442== by 0x400BA2: MAIN__ (in /home/ig25/Krempel/Cshift/Cs-test/a.out) ==17442== by 0x400D4A: main (in /home/ig25/Krempel/Cshift/Cs-test/a.out) ==17442== 0 The uninitialized variable is shape_data: 90 for (n = 0; n < rdim; n++) 91 { 92 shape_data[n] = shape->base_addr[n * GFC_DESCRIPTOR_STRIDE(shape,0)]; 93 if (shape_data[n] <= 0) 94 { Maybe we are missing something along the lines of the fix for PR 58883 here.