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

            Bug ID: 126001
           Summary: auto return type on method -> DW_TAG_unspecified_type
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon.marchi at polymtl dot ca
  Target Milestone: ---

This comes from GDB PR 24154:

https://sourceware.org/bugzilla/show_bug.cgi?id=24154

With:

---
int g = 22;

struct symbol
{
  int m_section;

  auto section_index () const
  { return m_section; }
};

auto func() {
    return g;
}

symbol s {12};


int main()
{
  return s.section_index() + func ();
};    
---

In the generated DWARF, the member function `section_index` has a return type
DW_TAG_unspecified_type:

0x00000067:     DW_TAG_subprogram
                  DW_AT_external [DW_FORM_flag_present] (true)
                  DW_AT_name [DW_FORM_strp]     ("section_index")
                  DW_AT_decl_file [DW_FORM_data1]      
("/home/smarchi/src/binutils-gdb/gdb/test.cpp")
                  DW_AT_decl_line [DW_FORM_data1]       (7)
                  DW_AT_decl_column [DW_FORM_data1]     (8)
                  DW_AT_linkage_name [DW_FORM_strp]    
("_ZNK6symbol13section_indexEv")
                  DW_AT_type [DW_FORM_ref4]     (0x00000087 "auto")
                  DW_AT_declaration [DW_FORM_flag_present]      (true)
                  DW_AT_object_pointer [DW_FORM_ref4]   (0x0000007b)

0x00000087:   DW_TAG_unspecified_type
                DW_AT_name [DW_FORM_strp]       ("auto")


This isn't terribly useful to the user, would it be possible to resolve it to
the real type (int, in this case)?

Note that the free function `func`, which also uses `auto` as its return type,
has the proper return type in the DWARF.

Compiler explorer link: https://godbolt.org/z/EnzaEz3rP
  • [Bug debug/126001] New: auto r... simon.marchi at polymtl dot ca via Gcc-bugs

Reply via email to