This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug debug/42801] New: C VLAs should use DW_AT_allocated
- From: "jan dot kratochvil at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jan 2010 10:18:32 -0000
- Subject: [Bug debug/42801] New: C VLAs should use DW_AT_allocated
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
FAIL: gcc (GCC) 4.4.3 20100119 (prerelease)
FAIL: gcc-4.4.2-20.fc12.x86_64 (Fedora 12)
SKIP: gcc (GCC) 4.5.0 20100119 (experimental) - N/A - blocked by PR debug/42800
------------------------------------------------------------------------------
Currently the type of a VLA (Variable Length Array) contains incorrect bounds
before the specific variable is allocated. Fortran uses DW_AT_allocated in
such case and GDB with archer-jankratochvil-vla patch properly avoids
evaluating the invalid bounds printing:
(gdb) ptype varx
type = <object is not allocated>
Currently with -O0 its DW_AT_location is defined even before it is allocated.
With -O2 its DW_AT_location is never defined (suboptimal VTA?). Offtopic here.
Still IMO the type should have DW_AT_allocated indicator and not depend on
never being evaluated when its variable has DW_AT_location undefined
(=<optimized out>).
This is not a regression bug.
------------------------------------------------------------------------------
static long
f (void)
{
long l = 0x7ffffffe; /* Pre-fill DW_AT_upper_bound of `a'. */
long unused = l;
return l | unused;
}
static int
g (long l)
{
char a[l]; /* gdb -ex 'b 13' -ex r -ex 'ptype a' */
return a[0];
}
int
main (void)
{
f ();
return g (5);
}
------------------------------------------------------------------------------
(gcc -o 1 1.c -m64 -Wall -g; ulimit -v 500000; gdb -nx -ex 'b 13' -ex r -ex
'ptype a' ./1)
------------------------------------------------------------------------------
Breakpoint 1, g (l=5) at 1.c:13
13 char a[l]; /* gdb -ex 'b 13' -ex r -ex 'ptype a' */
../../gdb/utils.c:1205: internal-error: virtual memory exhausted: can't
allocate 2147483647 bytes.
The problem is GDB internally allocates the type being printed (which is
suboptimal). Still it shows the type is valid but with incorrect bounds there.
Reducing the size will print the incorrect bound:
type = char [134217727]
--
Summary: C VLAs should use DW_AT_allocated
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: debug
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jan dot kratochvil at redhat dot com
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42801