http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52176
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-09 17:02:36 UTC --- gfortran generates the following code (original dump). I think, it's if ((real(kind=4)[0:] * restrict) __result->data == 0B) goto L.17; L.17:; D.2061 = __result->dim[0].ubound - __result->dim[0].lbound >= 0 ? (__result->dim[0].ubound - __result->dim[0].lbound) + 1 : 0; D.2062 = D.2061 != 2; if ((real(kind=4)[0:] * restrict) __result->data == 0B) ... else if (D.2062) where those equations are not used in an "if", if result->data == NULL. However, in the optimized dump, one finds: [air.F90 : 82:0] prephitmp.78_7 = [air.F90 : 82] __result_6(D)->data; [air.F90 : 82:0] if (prephitmp.78_7 == 0B) goto <bb 3>; <bb 3>: prephitmp.77_85 = __result_6(D)->dim[0].ubound; [air.F90 : 82:0] D.2085_25 = prephitmp.77_79 - D.2057_9; [air.F90 : 82:0] if (D.2085_25 >= 0) ... [air.F90 : 82:0] if (prephitmp.78_7 == 0B) goto <bb 8>; else goto <bb 9>; Thus, the bounds are always accessed in the "if", even if the result->data == NULL. However, in terms of the result, it does not seem to matter as far as I could see. However, I think the issue above is not related to the warning I see. valgrind can only track uninitialized variables which have been allocated ("malloc") but in this case "result" is a local variable, which should be stack allocated. >From the callee (state_vector, atmosphere.F90:187): real ,dimension(:) ,allocatable :: x x = this%air_puppet%coordinate() I think one should see such a valgrind error for allocatable components of allocatable/pointer derived types as then also "<var>.dim" is malloc'ed. If my analysis is correct, I do not see why valgrind warns. Nor do I understand the reordering of the middle end. But at least the case above looks as if it's not a wrong-code issue.