[LLVMbugs] [Bug 20324] New: boost::function generates invalid code when using precompiled headers

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jul 16 09:31:52 PDT 2014


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

            Bug ID: 20324
           Summary: boost::function generates invalid code when using
                    precompiled headers
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: himikof at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12777
  --> http://llvm.org/bugs/attachment.cgi?id=12777&action=edit
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

-- 
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/20140716/564c2118/attachment.html>


More information about the llvm-bugs mailing list