Skip to content

Wrong/missing debuginfo for struct with default constructor and nested struct declaration #89406

@m-mueller678

Description

@m-mueller678
#include<cstdlib>

struct A  {
    int x;

    A(){};

    struct Inner {
        int inner_inner = 0;
    };

    Inner inner;  // exclusive
};

int main(){
    A* a=reinterpret_cast<A*>(malloc(sizeof(A)));
    a->x=0;
}

Compiling this with clang and debugging with either gdb or lldb, A is reported as incomplete type or as 'no such type' depending on situation.
clang++-17 sample.cpp -g -std=c++20 && gdb a.out -ex 'ptype A'

GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...
No symbol "A" in current context.
(gdb) 

If the constructor is removed, it works as expected.

tested with both of these:

Ubuntu clang version 17.0.6 (++20231209124227+6009708b4367-1~exp1~20231209124336.77)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Ubuntu clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions