https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108621
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> --- The warning itself is bogus (false positive in the middle end). I get: Warning: ‘f.dim[idx.1_32].lbound’ may be used uninitialized [-Wmaybe-uninitialized] If I now look at the 021t.ssa dump, I see: f.data = 0B; ... _1 = f.data; cfi.0.base_addr = _1; ... _2 = cfi.0.base_addr; if (_2 != 0B) goto <bb 3>; [INV] else goto <bb 6>; [INV] ... <bb 4> : _3 = f.dim[idx.1_32].lbound; ... <bb 6> : fun (&cfi.0); The basic block <bb 4> is the only place where idx.1_32 gets used - but as f.data == NULL, we directly jump to <bb 6>. Seemingly, the range/value propagation from f.data to cfi.0.base_addr did not work. — Thus and probably unsurprisingly, the warning is gone once optimization has been turned on (-Og, -Os or -O1 are sufficient). → This is now tracked in the new PR middle-end/108906 * * * Still, we can do better in the FE by producing less code when we know that the dummy argument is 'intent(out)'. That's what the lightly tested patch below does. (Note: It fixes the testcase of comment 0, but when changing the intent, e.g., to 'intent(inout)' the bogus warning will re-appear.) TODO: I think something similar needs to be done for allocatable + 'intent(out)', except that we still need to handle the DEALLOCATE in the caller. --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -5675,3 +5675,3 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) - if (e->rank == 0) + if (e->rank == 0 && (!fsym->attr.pointer || fsym->attr.intent != INTENT_OUT)) { @@ -5680,3 +5680,3 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) } - else + else if (!fsym->attr.pointer || fsym->attr.intent != INTENT_OUT) { @@ -5697,2 +5697,5 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym) + if (fsym->attr.pointer && fsym->attr.intent == INTENT_OUT) + goto done; + /* When allocatable + intent out, free the cfi descriptor. */