LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 19238 - Debug info not generated correctly for function static variables
Summary: Debug info not generated correctly for function static variables
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: 3.4
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
: 23164 44695 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-03-24 19:43 PDT by Craig MacKenzie
Modified: 2021-11-17 07:14 PST (History)
8 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Craig MacKenzie 2014-03-24 19:43:57 PDT
#include<stdio.h>
int main() {
    static int X = 10;
    {
        static bool X = false;
        printf("...");
    }
    printf("...");
}

If you compile the code above with clang 3.4 and break at the printf() statements (gdb or lldb) then p X will always show X to be 10. The same code compiled with GCC shows X to be false in the first case and 10 in the second as expected.
Comment 1 Eric Christopher 2014-03-25 21:22:54 PDT
Looks like we're missing the lexical block for the inner range.
Comment 2 Amjad Aboud 2015-05-13 06:25:34 PDT
Same issue is true for typedef and records (struct, union, and class).
I have a fix for all these cases, in both Clang and LLVM.
I will upload it for review ASAP.
Comment 3 Paul Robinson 2015-05-22 16:38:30 PDT
*** Bug 23164 has been marked as a duplicate of this bug. ***
Comment 4 Kristina Bessonova 2021-11-17 07:12:18 PST
*** Bug 44695 has been marked as a duplicate of this bug. ***
Comment 5 Kristina Bessonova 2021-11-17 07:14:28 PST
Another attempt to fix this

* https://reviews.llvm.org/D113741 (backend)
* https://reviews.llvm.org/D113743 (clang)