This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

debug/10002: gcc -g sometimes places labels beyond the end of the function


>Number:         10002
>Category:       debug
>Synopsis:       gcc -g sometimes places labels beyond the end of the function
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 08 14:26:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Werner Almesberger
>Release:        3.3 20030303 (prerelease)
>Organization:
>Environment:
System: Linux ar 2.4.18 #5 Mon Mar 18 09:25:24 ART 2002 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure --prefix=/usr/local/gcc20030303/ --enable-languages=c
>Description:
gcc -g sometimes places labels beyond the end of the function,
so a breakpoint at such a label is never taken. This seems to happen
consistently if the function is void.

>How-To-Repeat:
Example (with Red Hat's gcc 3.1 20011127 on ia32):

$ cat <<EOF >foo.c
void main(void)
{
label:
    return;
}
EOF
$ gcc -w -g foo.c
$ readelf -w a.out
...
     DW_AT_name        : (indirect string, offset: 0x50): label
...
     DW_AT_low_pc      : 0x80483aa 134513578
...
$ objdump -d a.out
...
08048398 <main>:
...
 80483a8:       c9                      leave
 80483a9:       c3                      ret
 80483aa:       89 f6                   mov    %esi,%esi
...

>Fix:
My very ugly work-around is to add an asm("") after the label.
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]