https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86985
Bug ID: 86985
Summary: https://gcc.gnu.org/bugzilla/enter_bug.cgi?product=gcc
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: osandov at osandov dot com
Target Milestone: ---
It is currently impossible for a debugger to distinguish between a zero-length
and a flexible array given the debug info generated by GCC:
$ cat zero_length.c
struct {
int foo;
int bar[0];
} baz;
$ cat flexible.c
struct {
int foo;
int bar[];
} baz;
$ gcc -g -c zero_length.c
$ gcc -g -c flexible.c
$ gdb -batch -ex 'ptype baz' zero_length.o
type = struct {
int foo;
int bar[];
}
$ gdb -batch -ex 'ptype baz' flexible.o
type = struct {
int foo;
int bar[];
}
However, when compiling with clang:
$ clang -g -c zero_length.c
$ clang -g -c flexible.c
$ gdb -batch -ex 'ptype baz' zero_length.o
type = struct {
int foo;
int bar[0];
}
$ gdb -batch -ex 'ptype baz' flexible.o
type = struct {
int foo;
int bar[];
}
This distinction would be useful for certain tools. For example, I have a tool
which feeds the structure definitions from debug info back into a C compiler,
but this fails in some cases where zero-length and flexible array types are not
interchangable.