[LLVMbugs] [Bug 18552] New: An extern declaration in block scope refers to an incorrect variable.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jan 19 21:51:52 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18552

            Bug ID: 18552
           Summary: An extern declaration in block scope refers to an
                    incorrect variable.
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kariya_mitsuru at hotmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I think that the following sample code should return 4, but clang returns 1.


// --- main.cc begin ---
static int i = 1;       // #1 i has internal linkage
int g() {
    int i = 2;          // #2 i has no linkage
    {
        extern int i;   // #3
        return i;
    }
}

int main()
{
    return g();
}
// --- main.cc end ---

// --- sub.cc begin ---
int i = 4;              // #4 i has external linkage
// --- sub.cc end ---


According to C++11 standard 3.5 p6, #3 should refer to #4 because #1 is not
visible from the point #3.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140120/a5e879f0/attachment.html>


More information about the llvm-bugs mailing list