[llvm-bugs] [Bug 28662] New: Type with no linkage in signature: symbols for unique entities link together

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 22 04:51:41 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28662

            Bug ID: 28662
           Summary: Type with no linkage in signature: symbols for unique
                    entities link together
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Clang produces symbols for entities which cannot possibly be referenced from
another translation unit in such a way that distinct entities link together.

In the following program, the templates in question are neither equivalent nor
functionally equivalent.

Online compiler: http://melpon.org/wandbox/permlink/okS5TiGDAVgd8tb0

### SOURCE (a.cc):
extern "C" void abort();
void bar();

namespace {
  template <typename T> struct A { A(int); char sizer[1]; };
}

template <typename T> void foo(char (*)[sizeof A<T>(T(0))]) {
  static unsigned cnt = 0;
  if (cnt++) abort();
}

int main(void) { bar(); foo<int>(0); }


### SOURCE (b.cc):
extern "C" void abort();

namespace {
  template <typename T> struct A { A(int); char sizer[2]; };
}

template <typename T> void foo(char (*)[sizeof A<T>(T(0))]) {
  static unsigned cnt = 0;
  if (cnt++) abort();
}

void bar() { foo<int>(0); }


### COMMANDS:
clang++ -c -o a.o -std=c++11 a.cc
clang++ -c -o b.o -std=c++11 b.cc
clang++ -o a.out a.o b.o
./a.out


### EXPECTED OUTPUT:
rc=0


### ACTUAL OUTPUT:
(aborts)


### COMPILER VERSION INFO (clang++ -v):
clang version 4.0.0 (trunk 276290)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/llvm-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.3
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

-- 
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/20160722/05111d5f/attachment.html>


More information about the llvm-bugs mailing list