public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "massarelli at diag dot uniroma1.it" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/95835] New: Wrong line information at Og
Date: Tue, 23 Jun 2020 09:05:31 +0000	[thread overview]
Message-ID: <bug-95835-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 95835
           Summary: Wrong line information at Og
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: massarelli at diag dot uniroma1.it
  Target Milestone: ---

Line information is wrong at line 6. 
Line 6 should not be hit as it is the declaration of variables. 
>From the disassembly, it seems that the program is actually executing line 5.

$ cat a.c
int a ;
int main () {
   for (;
        a < 2;
        a++)  {
        int i, j, k;
   }
}

$ cat -n a.c
     1  int a ;
     2  int main () {
     3     for (;
     4          a < 2;
     5          a++)  {
     6          int i, j, k;
     7     }
     8  }

$ gcc -v 
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/tmp/gcc_build --disable-multilib
--enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200619 (experimental) (GCC) 

$ gdb -v
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git

$ gcc -Og -g -o opt a.c

$ gdb opt
(gdb) b main
Breakpoint 1 at 0x400486: file a.c, line 3.
(gdb) r
Starting program: opt 
Breakpoint 1, main () at aaa.c:3
3          for (;
(gdb) s
4               a < 2;
(gdb) s
6               int i, j, k;
(gdb) disassemble
Dump of assembler code for function main:
   0x0000000000400486 <+0>:     jmp    0x400491 <main+11>
=> 0x0000000000400488 <+2>:     add    $0x1,%eax
   0x000000000040048b <+5>:     mov    %eax,0x200b9b(%rip)        # 0x60102c
<a>
   0x0000000000400491 <+11>:    mov    0x200b95(%rip),%eax        # 0x60102c
<a>
   0x0000000000400497 <+17>:    cmp    $0x1,%eax
   0x000000000040049a <+20>:    jle    0x400488 <main+2>
   0x000000000040049c <+22>:    mov    $0x0,%eax
   0x00000000004004a1 <+27>:    retq   
End of assembler dump.
(gdb)

             reply	other threads:[~2020-06-23  9:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  9:05 massarelli at diag dot uniroma1.it [this message]
2020-06-23 11:22 ` [Bug c/95835] " rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-95835-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).