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

           Summary: Scope of extern declarations extend past enclosing
                    block
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


When multiple extern declarations for an identifier exist at block scope, the
scope of the declaration incorrectly extends past the block containing the
declaration.

For example, the following program prints 10 instead of 20 when compiled with
clang:

    #include <stdio.h>

    int i = 10;

    int main(void) {
        int i = 20;
        {
            extern int i;
            extern int i;
        }
        printf("%d\n", i);
        return 0;
    }

If one of the "extern int i;" lines is removed, 20 will be printed.  gcc and
Intel print 20 both cases.  The same issue occurs if the second extern
declaration is in a nested block:

    #include <stdio.h>

    int i = 10;

    int main(void) {
        int i = 20;
        {
            extern int i;
            {
                extern int i;
            }
        }

        printf("%d\n", i);
        return 0;
    }

This was tested with clang version 3.0 (trunk 131958).

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to