Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect debug info generated for variable size arrays #26308

Open
tberghammer opened this issue Dec 23, 2015 · 0 comments
Open

Incorrect debug info generated for variable size arrays #26308

tberghammer opened this issue Dec 23, 2015 · 0 comments
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category

Comments

@tberghammer
Copy link
Collaborator

Bugzilla Link 25934
Version unspecified
OS Linux
CC @pogo59,@zygoloid

Extended Description

Reproducing the issue:

  • Compile the followoing code snippet with "clang++ -g var.cpp":
    int main() {
    for (int i = 0; i < 10; ++i) {
    int x[i + 1];
    x[0]++;
    }
    }
  • Inspect the debug info for variable 'x'

The relevant parts of the debug info:
<4><6b>: Abbrev Number: 5 (DW_TAG_variable)
<6c> DW_AT_location : 0x0 (location list)
<70> DW_AT_name : (indirect string, offset: 0x71): x
<74> DW_AT_decl_file : 1
<75> DW_AT_decl_line : 3
<76> DW_AT_type : <0x84>

<1><84>: Abbrev Number: 7 (DW_TAG_array_type)
<85> DW_AT_type : <0x7d>
<2><89>: Abbrev Number: 8 (DW_TAG_subrange_type)
<8a> DW_AT_type : <0x8f>
<2><8e>: Abbrev Number: 0
<1><8f>: Abbrev Number: 9 (DW_TAG_base_type)
<90> DW_AT_name : (indirect string, offset: 0x73): sizetype
<94> DW_AT_byte_size : 8
<95> DW_AT_encoding : 7 (unsigned)
<1><96>: Abbrev Number: 0

The problem is that clang specifies a DW_TAG_subrange_type under DW_TAG_array_type but is fails to fill it in with some information specifying the number of elements in the array (DW_AT_count or DW_AT_upper_bound).

The issue is reproduced with clang 3.5.0 and with 3.8.0 (trunk 256170). Gcc 4.8.4 generates correct debug info with producing a DW_AT_upper_bound containing a dwarf expression to a memory location containing the current array size.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category
Projects
None yet
Development

No branches or pull requests

1 participant