<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - multiple definitions of static variables inside functions" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23838&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=qqUl17T1JtVDwVRGOSWh2HKsjFxHCeQ7yuhMouxCF74&s=HtJBvuopO3fORffKJK6dR1MRCOj3X2gWH_e1EM0ZVPQ&e=">23838</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>multiple definitions of static variables inside functions
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>heavenandhell171@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang is not generating comdats for static variables of classes with virtual
members.

$ cat > h.h
class error_category {
public:
  virtual void fn() {}
};

inline error_category& make_error_code() {
  static error_category C;
  return C;
}

$ cat > t1.cpp
#include "h.h"

int main(int argc, char **argv) {
  make_error_code();
  return 0;
}

$ cat > t2.cpp
#include "h.h"

void foo() {
  make_error_code();
}

$ clang++ -std=c++11 t1.cpp t2.cpp -target i686-windows-gnu
C:\Dev\MSys2\tmp\test2-135e49.o:(.data+0x0): multiple definition of
`make_error_code()::C'
C:\Dev\MSys2\tmp\test-bf4e7c.o:(.data+0x0): first defined here
clang++.exe: error: linker command failed with exit code 1 (use -v to see
invocation)

I'm targeting Mingw here, but it doesn't work when targeting MSVC either.
Removing virtual from 'void fn()' makes clang work.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>