<html>
    <head>
      <base href="http://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 --- - IMAGE_COMDAT_SELECT_ASSOCIATIVE sections produced with an invalid comdat"
   href="http://llvm.org/bugs/show_bug.cgi?id=19969">19969</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>IMAGE_COMDAT_SELECT_ASSOCIATIVE sections produced with an invalid comdat
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rafael.espindola@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, rnk@google.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given 

struct foo {
  foo();
};
template <class T> struct bar {
  static foo zed;
};
template <class T>
foo bar<T>::zed;
template class bar<int>;


clang produces (after some simplification)

target triple = "i686-pc-windows-msvc"
%struct.foo = type { i8 }
@"\01?zed@?$bar@H@@2Ufoo@@A" = weak_odr global %struct.foo zeroinitializer,
align 1
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void
()*, i8* } { i32 65535, void ()* @"\01??__Ezed@?$bar@H@@2Ufoo@@A@YAXXZ", i8*
getelementptr inbounds (%struct.foo\
* @"\01?zed@?$bar@H@@2Ufoo@@A", i32 0, i32 0) }]
define linkonce_odr void @"\01??__Ezed@?$bar@H@@2Ufoo@@A@YAXXZ"() {
entry:
  %call = call x86_thiscallcc %struct.foo* @"\01??0foo@@QAE@XZ"(%struct.foo*
@"\01?zed@?$bar@H@@2Ufoo@@A")
  ret void
}
declare x86_thiscallcc %struct.foo* @"\01??0foo@@QAE@XZ"(%struct.foo* returned)

which seems reasonable. The problem is that the llc produced assembly has

.section        .bss,"bw",discard,"?zed@?$bar@H@@2Ufoo@@A"
...
.section        .CRT$XCU,"rd",associative .bss,"?zed@?$bar@H@@2Ufoo@@A"

The symbol ?zed@?$bar@H@@2Ufoo@@A" cannot be in two sections at the same time.

Given the description of how assoc works in the coff documentation, it looks
like the comdat name is not actually used. It is kept iff the associated
section is kept.

Right now this is not noticed because the comdat is the .section is ignored and
the produce .obj end up having the first output symbol as a comdat, what ever
that happens to be. In the above case, none at all.

msvc seems to create a symbol just for this (...$initializer$...). We probably
just produce a temp symbol.</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>