https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67192

            Bug ID: 67192
           Summary: Backward-goto in loop can get wrong line number
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arnez at linux dot vnet.ibm.com
  Target Milestone: ---

This bug causes a number of failures in the GDB test suite, e.g. with
checkpoint.exp.  I can reproduce it with the command line:

    gcc -fdump-tree-gimple-lineno -o foo.o -c -g foo.c

==== foo.c ====
extern int bar(void);
extern int baz(void);

extern int foo(int x);

int foo(int x)
{
  for (;;)
    {
      if (bar ())
        break;
      baz ();
    }
  baz (); /* Line 14. */
}

==== foo.c.004t.gimple ====
foo (int x)
[foo.c:7:1] {
  int D.1415;

  <D.1413>:
  [foo.c:10:11] D.1415 = bar ();
  [foo.c:10:10] if (D.1415 != 0) goto <D.1416>; else goto <D.1417>;
  <D.1416>:
  [foo.c:11:2] goto <D.1412>;
  <D.1417>:
  [foo.c:12:7] baz ();
  [foo.c:14:3] goto <D.1413>; /* <== WRONG! Should be [foo.c:13:5]. */
  <D.1412>:
  [foo.c:14:3] baz ();
}

Reply via email to