public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/101928] New: Incorrect argument list for varardic functions
@ 2021-08-16  5:02 liyd2021 at gmail dot com
  2021-08-16  9:23 ` [Bug ipa/101928] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: liyd2021 at gmail dot com @ 2021-08-16  5:02 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug ipa/101928] Incorrect argument list for varardic functions
  2021-08-16  5:02 [Bug debug/101928] New: Incorrect argument list for varardic functions liyd2021 at gmail dot com
@ 2021-08-16  9:23 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-08-16  9:23 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jamborm at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2021-08-16
     Ever confirmed|0                           |1
          Component|debug                       |ipa
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
We're creating a clone and have

 <1><f1>: Abbrev Number: 14 (DW_TAG_subprogram)
    <f2>   DW_AT_name        : (indirect string, offset: 0x58): varargs
    <f6>   DW_AT_decl_file   : 1
    <f7>   DW_AT_decl_line   : 2
    <f8>   DW_AT_decl_column : 13
    <f9>   DW_AT_prototyped  : 1
    <f9>   DW_AT_inline      : 1        (inlined)
    <fa>   DW_AT_sibling     : <0x121>
 <2><fe>: Abbrev Number: 15 (DW_TAG_formal_parameter)
    <ff>   DW_AT_name        : q0
    <102>   DW_AT_decl_file   : 1
    <103>   DW_AT_decl_line   : 2
    <104>   DW_AT_decl_column : 25
    <105>   DW_AT_type        : <0xea>
 <2><109>: Abbrev Number: 15 (DW_TAG_formal_parameter)
    <10a>   DW_AT_name        : q1
    <10d>   DW_AT_decl_file   : 1
    <10e>   DW_AT_decl_line   : 2
    <10f>   DW_AT_decl_column : 33
    <110>   DW_AT_type        : <0xea>
 <2><114>: Abbrev Number: 16 (DW_TAG_unspecified_parameters)
 <2><115>: Abbrev Number: 17 (DW_TAG_variable)
    <116>   DW_AT_name        : ap
    <119>   DW_AT_decl_file   : 1
    <11a>   DW_AT_decl_line   : 3
    <11b>   DW_AT_decl_column : 11
    <11c>   DW_AT_type        : <0x9b>
 <2><120>: Abbrev Number: 0
 <1><121>: Abbrev Number: 18 (DW_TAG_subprogram)
    <122>   DW_AT_abstract_origin: <0xf1>
    <126>   DW_AT_low_pc      : 0x0
    <12e>   DW_AT_high_pc     : 0xb
    <136>   DW_AT_frame_base  : 1 byte block: 9c        (DW_OP_call_frame_cfa)
    <138>   DW_AT_GNU_all_call_sites: 1
 <2><138>: Abbrev Number: 19 (DW_TAG_formal_parameter)
    <139>   DW_AT_abstract_origin: <0xfe>
    <13d>   DW_AT_location    : 1 byte block: 55        (DW_OP_reg5 (rdi))
 <2><13f>: Abbrev Number: 19 (DW_TAG_formal_parameter)
    <140>   DW_AT_abstract_origin: <0x109>
    <144>   DW_AT_location    : 1 byte block: 54        (DW_OP_reg4 (rsi))
 <2><146>: Abbrev Number: 16 (DW_TAG_unspecified_parameters)
 <2><147>: Abbrev Number: 20 (DW_TAG_variable)
    <148>   DW_AT_abstract_origin: <0x115>
    <14c>   DW_AT_location    : 2 byte block: 91 60     (DW_OP_fbreg: -32)
 <2><14f>: Abbrev Number: 21 (DW_TAG_formal_parameter)
    <150>   DW_AT_abstract_origin: <0x109>
    <154>   DW_AT_const_value : 1
 <2><155>: Abbrev Number: 21 (DW_TAG_formal_parameter)
    <156>   DW_AT_abstract_origin: <0xfe>
    <15a>   DW_AT_const_value : 0
 <2><15b>: Abbrev Number: 0
 <1><15c>: Abbrev Number: 0

we're producing

varargs.constprop (int q0, int q1)
{
  struct  ap[1];

  <bb 2> [local count: 1073741824]:
  # DEBUG q1 => 1
  # DEBUG q0 => 0
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  __builtin_va_start (&ap, 0);
  ap ={v} {CLOBBER};
  return;

}

and call it as

main ()
{
  <bb 2> [local count: 1073741824]:
  # DEBUG BEGIN_STMT
  varargs.constprop (0, 1, 2);
  return 0;

so IPA-CP did some incomplete transform here it seems.  Martin?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-16  9:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-16  5:02 [Bug debug/101928] New: Incorrect argument list for varardic functions liyd2021 at gmail dot com
2021-08-16  9:23 ` [Bug ipa/101928] " rguenth at gcc dot gnu.org

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).