https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91359
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P4 Status|UNCONFIRMED |NEW Last reconfirmed| |2019-08-05 CC| |kargl at gcc dot gnu.org Summary|GFORTRAN [NNNNN RETURN] of |logical function X returns |.FALSE. logical function X |.TRUE. - Warning: |returns .TRUE. after [if |spaghetti code |(.not.X) goto NNNNN] - | |Warning: spaghetti code | Ever confirmed|0 |1 --- Comment #1 from kargl at gcc dot gnu.org --- The options -finit-local-zero and -fno-automatic are unimportant. Compiling the code in comment #1 with -fdump-tree-original reveals the problem as the function is translated into zero () { logical(kind=4) __result_zero; goto __label_000002; __label_000001:; return; __label_000002:; __result_zero = 0; if (!__result_zero) goto __label_000001; L.1:; return __result_zero; return __result_zero; } Notice the first 'return' statement has no value to return. A work around to to introduce a RESULT variable. This is translated to function zero() result(a) logical a goto 2 1 return 2 a = .false. if (.not. a) goto 1 return end zero () { logical(kind=4) a; goto __label_000002; __label_000001:; return a; __label_000002:; a = 0; if (!a) goto __label_000001; L.1:; return a; return a; }