[LLVMbugs] [Bug 14638] New: assert "May only branch on boolean predicates" fails for assignment to bitfield

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Dec 18 14:56:37 PST 2012


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

             Bug #: 14638
           Summary: assert "May only branch on boolean predicates" fails
                    for assignment to bitfield
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: clang at martinien.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Hi,

for the following file, code generation asserts on latest trunk (works with
clang 3.2):

bf-assert.cpp:

struct A {
    bool m_sorted : 1;
    //bool m_sorted;
};

void func1()
{
    A a1;
    int i=0, j=0;
    if ((a1.m_sorted = (i > 0 && j >= i)))
        ;
}


clang: /local/mar_/llvmtrunk/lib/VMCore/Instructions.cpp:725: void
llvm::BranchInst::AssertOK(): Assertion
`getCondition()->getType()->isIntegerTy(1) && "May only branch on boolean
predicates!"' failed.
0  clang           0x0000000001bcd262
1  clang           0x0000000001bcd6f3
2  libpthread.so.0 0x00002ab3acda96b0
3  libc.so.6       0x00002ab3ad966945 gsignal + 53
4  libc.so.6       0x00002ab3ad967f21 abort + 385
5  libc.so.6       0x00002ab3ad95f810 __assert_fail + 240
6  clang           0x0000000001b5bc5a
7  clang           0x00000000007e76e3
8  clang           0x00000000008c2a0e
clang::CodeGen::CodeGenFunction::EmitBranchOnBoolExpr(clang::Expr const*,
llvm::BasicBlock*, llvm::BasicBlock*) + 798
9  clang           0x00000000008b2e26
clang::CodeGen::CodeGenFunction::EmitIfStmt(clang::IfStmt const&) + 390
10 clang           0x00000000008b2280
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 496
11 clang           0x00000000008b725b
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, clang::CodeGen::AggValueSlot) + 235
12 clang           0x00000000008b293f
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 351
13 clang           0x00000000008b20b5
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 37
14 clang           0x00000000008c2007
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 663
15 clang           0x00000000007c992d
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl)
+ 621
16 clang           0x00000000007c6f54
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl) + 228
17 clang           0x00000000007c8f30
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 800
18 clang           0x00000000007cdd35
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 949
19 clang           0x00000000007c1c1f
20 clang           0x00000000007c1027
21 clang           0x00000000008dce63 clang::ParseAST(clang::Sema&, bool, bool)
+ 435


When changing the bitfield bool to a normal bool it works.


Run script:

/local/mar_/llvmtrunk_opt/Release+Asserts/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -
disable-free -main-file-name bf-assert.cpp -mrelocation-model static
-mdisable-fp-elim -fmath-errno -masm-verbose
 -mconstructor-aliases -munwind-tables -target-cpu x86-64
-target-linker-version 11 -momit-leaf-frame-pointer -fd
eprecated-macro -ferror-limit 19 -fmessage-length 113 -mstackrealign
-fobjc-runtime=gcc -fcxx-exceptions -fexcept
ions -fdiagnostics-show-option -fcolor-diagnostics -x c++ bf-assert.cpp

Since it is a regression from 3.2 I file it as a release blocker, please change
if that's not appropriate.

Best regards,
Martin

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list