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

            Bug ID: 19480
           Summary: Miscompile when linking variable templates
                    instantiated from similarly named local types
           Product: clang
           Version: 3.4
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++1y
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

The functions foo() in the program below can only reside in their native
translation unit.
The local classes Foo in each foo() are distinct entities.

Clang seems to treat the x<Foo> specializations as one entity.


### TRANSLATION UNIT A:
> cat badvartmpllinkA.cc 
template <typename T> int x = 42;

static int &foo() {
   struct Foo { };
   return x<Foo>;
}

int &bar() { return foo(); }
Return:  0x00:0


### TRANSLATION UNIT B:
> cat badvartmpllinkB.cc 
template <typename T> int x = 42;

static int &foo() {
   struct Foo { };
   return x<Foo>;
}

int &bar();

int main() { &bar() == &foo() ? throw 0 : (void)0; }
Return:  0x00:0


### COMPILER INVOCATION:
> clang++ -std=c++1y -pedantic-errors badvartmpllinkA.cc badvartmpllinkB.cc -o 
> badvartmpllink                    
Return:  0x00:0


### OUTPUT FROM RESULTING BINARY:
> ./badvartmpllink 
terminate called after throwing an instance of 'int'
Aborted (core dumped)
Return:  0x86:134


### VERSION INFORMATION:
> clang++ -v
clang version 3.4 (tags/RELEASE_34/final)
Target: powerpc64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.4
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Selected GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Return:  0x00:0

-- 
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