https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99816
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-debug Last reconfirmed| |2021-03-29 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- The IL from the frontend is (with line numbers): __attribute__((fn spec (". w w "))) void sub (real(kind=4)[0:D.3943] * restrict a, integer(kind=4) & restrict n) [t.f90:1:16] { integer(kind=8) ubound.0; integer(kind=8) size.1; integer(kind=4) i; integer(kind=8) D.3943; bitsizetype D.3944; sizetype D.3945; [t.f90:1:18] ubound.0 = [t.f90:1:18] (integer(kind=8)) [t.f90:1:18] *n; [t.f90:1:18] size.1 = [t.f90:1:18] NON_LVALUE_EXPR <ubound.0>; [t.f90:1:18] size.1 = [t.f90:1:18] MAX_EXPR <size.1, 0>; [t.f90:1:18] D.3943 = [t.f90:1:16] size.1 + -1; [t.f90:1:18] D.3944 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <size.1> * 32; [t.f90:1:18] D.3945 = (sizetype) NON_LVALUE_EXPR <size.1> * 4; [t.f90:3:22] { integer(kind=4) D.3938; [t.f90:3:22] D.3938 = [t.f90:3:22] *n; [t.f90:3:17] i = 1; [t.f90:3:17] while (1) { [t.f90:5:34] { logical(kind=4) D.3941; [t.f90:3:17] D.3941 = [t.f90:3:17] i > D.3938; [t.f90:3:17] if (D.3941) [t.f90:3:17] goto L.2; [t.f90:4:15] [t.f90:4:15] ([t.f90:4:15] *a)[[t.f90:4:15] (integer(kind=8)) i + -1] = (real(kind=4)) i; [t.f90:4:15] __label_000100:; [t.f90:5:34] L.1:; [t.f90:3:17] i = [t.f90:3:17] i + 1; } } [t.f90:5:34] L.2:; } [t.f90:6:13] return; } where we have two labels / empty stmts with line number 5, one inside and one outside of the loop. Note the actual "continue" is the end of the while loop. gimplification turns this into [t.f90:3:22] { integer(kind=4) D.3938; [t.f90:3:22] D.3938 = [t.f90:3:22] *n; [t.f90:3:17] i = 1; <D.3974>: [t.f90:5:34] { logical(kind=4) D.3941; [t.f90:3:17] D.3941 = i > D.3938; [t.f90:3:17] if (D.3941 != 0) goto L.2; else goto <D.3975>; <D.3975>: [t.f90:4:15] _5 = (integer(kind=8)) i; [t.f90:4:15] _6 = _5 + -1; [t.f90:4:15] _7 = (real(kind=4)) i; [t.f90:4:15] [t.f90:4:15] [t.f90:4:15] (*a)[_6] = _7; [t.f90:4:15] __label_000100: [t.f90:5:34] L.1: [t.f90:3:17] i = i + 1; } [t.f90:3:17] goto <D.3974>; [t.f90:5:34] L.2: } note how the while (1) backwards jump gets line number 3. How the Fortran frontend uses LOOP_EXPR but does control flow by itself makes it difficult to deal with this.