<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 --- - boost::function generates invalid code when using precompiled headers"
   href="http://llvm.org/bugs/show_bug.cgi?id=20324">20324</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>boost::function generates invalid code when using precompiled headers
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>himikof@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>Created <span class=""><a href="attachment.cgi?id=12777" name="attach_12777" title="The reduced test case">attachment 12777</a> <a href="attachment.cgi?id=12777&action=edit" title="The reduced test case">[details]</a></span>
The reduced test case

A function-template-local const static POD variable in boost::function
implementation (from Boost 1.55) emits invalid LLVM IR when using precompiled
headers.
The variables from specializations are emitted as internal constants, not
linkonce_odr constants, and references to this variable are sometimes wrong:
they reference the variable from a different specialization, using bitcast to
convert its type.

The impact of this bug seems quite severe: it makes boost::function
constructors sometimes crash if precompiled headers are used.

See the attached (standalone) testcase, reduced from Boost.Function
implementation. It has the following structure:
  fr.h - several definitions reduced from Boost.Function
  stdafx.h - the header PCH is generated from (includes fr.h)
  test.cpp - the main file
  make.sh - a simple build script

The boost::fr::assign_to::stored_vtable is the offending variable. There are
two runtime asserts at the end of boost::fr::assign_to that should always hold,
but they fail when "test" binary is run. Also, the invalid bitcast can be seen
in the test.ir file by "grep -E 'bitcast.+stored_vtable' test.ir".

This bug disappears if PCH is not used, and code is compiled directly. Also, I
could not reproduce it on clang 3.3.

Clang version:
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-pc-linux-gnu
Thread model: posix
Selected GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3</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>