https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101928
Bug ID: 101928
Summary: Incorrect argument list for varardic functions
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: liyd2021 at gmail dot com
Target Milestone: ---
Affected versions: gcc 11.1.0 with gdb (Ubuntu 20.04.2)
(terminal) $ cat simple.c && gcc -g -O2 simple.c
static void varargs(int q0, int q1, ...) {
va_list ap;
va_start(ap, q1);
}
int main() {
varargs(0, 1, 2);
}
--------------------
(terminal) $ cat run.gdb
b varargs
r
ptype varargs
q
(terminal) $ gdb -x run.gdb a.out
Breakpoint 1, varargs (q0=0, q1=1, q1=1, q0=0) at simple.c:2
2 static void varargs(int q0, int q1, ...) {
type = void (int, int, int, int) <-- BUG, duplicated arguments
--------------------
Compile with O0/Og will not trigger this behavior. The static for `varargs` is
also required. LLDB rejected this debug info:
(terminal) $ lldb a.out
(lldb) b varargs
error: simple {0x0000000c}: DIE has DW_AT_ranges(0xc) attribute, but range
extraction failed (missing or invalid range list table), please file a bug and
attach the file at the start of this error message