Skip to content

Assigning to an "extern" variable does not cause type information to be emitted #116047

@labath

Description

@labath
$ clang -c -o - -x c++ -g - <<<"struct S {}; extern S *s; void f() {s = new S(); }" | llvm-dwarfdump - | grep DW_TAG_structure_type
$ clang -c -o - -x c++ -g - <<<"struct S {}; S *s; void f() {s = new S(); }" | llvm-dwarfdump - | grep DW_TAG_structure_type
0x00000033:   DW_TAG_structure_type

I believe the first command should also produce debug info for struct S. We cannot rely on the type information to be emitted in the compilation unit defining s as it may not even have access to the definition (it could be treating it opaquely as a forward-declaration). Interestingly, not even -fstandalone-debug causes the type to be emitted.

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