[llvm-bugs] [Bug 28653] New: clang crashes on C++ code invoking __builtin_signbit with value of incompatible type: Assertion `NumBits >= MIN_INT_BITS && "bitwidth too small"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 21 16:17:19 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28653

            Bug ID: 28653
           Summary: clang crashes on C++ code invoking __builtin_signbit
                    with value of incompatible type: Assertion `NumBits >=
                    MIN_INT_BITS && "bitwidth too small"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk crashes (without any proper diagnostics) when compiling
the following C++ test case on x86_64-linux-gnu in both 32-bit and 64-bit
modes. 

The code is accepted by 3.8.x (which seems unintended) and is rejected by 3.7.x
with proper error messages (consistent with GCC's behavior). 

This is related to PR 28172, but a different issue. 


$ clang++ -v
clang version 4.0.0 (trunk 276243)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.1.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang++-3.8 -c small.cpp
$ clang++-3.7.0 -c small.cpp
small.cpp:3:31: error: cannot initialize a parameter of type 'double' with an
lvalue of type 'void ()'
  bool b = __builtin_signbit (f);
                              ^
1 error generated.
$ g++-6.1 -c small.cpp
small.cpp: In function ‘void f()’:
small.cpp:3:32: error: non-floating-point argument in call to function
‘__builtin_signbit’
   bool b = __builtin_signbit (f);
                                ^
$
$ clang++ -c small.cpp
clang-4.0: /tmp/llvm-builder/llvm-source-trunk/lib/IR/Type.cpp:235: static
llvm::IntegerType* llvm::IntegerType::get(llvm::LLVMContext&, unsigned int):
Assertion `NumBits >= MIN_INT_BITS && "bitwidth too small"' failed.
#0 0x0000000001d96685 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1d96685)
#1 0x0000000001d9473e llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-4.0+0x1d9473e)
#2 0x0000000001d948a0 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-4.0+0x1d948a0)
#3 0x00007ffca35e6340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007ffca23d7cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007ffca23db0d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007ffca23d0b86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007ffca23d0c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000001a1e3b4 llvm::IntegerType::get(llvm::LLVMContext&, unsigned int)
(/usr/local/clang-trunk/bin/clang-4.0+0x1a1e3b4)
#9 0x0000000002148989 EmitSignBit(clang::CodeGen::CodeGenFunction&,
llvm::Value*) (/usr/local/clang-trunk/bin/clang-4.0+0x2148989)
#10 0x0000000002167e03
clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::FunctionDecl const*,
unsigned int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot)
(/usr/local/clang-trunk/bin/clang-4.0+0x2167e03)
#11 0x0000000002099a40
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot)
(/usr/local/clang-trunk/bin/clang-4.0+0x2099a40)
#12 0x00000000008a58f4 (anonymous
namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*)
(/usr/local/clang-trunk/bin/clang-4.0+0x8a58f4)
#13 0x00000000020bfe09 (anonymous
namespace)::ScalarExprEmitter::Visit(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-4.0+0x20bfe09)
#14 0x00000000008a7828 (anonymous
namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*)
(/usr/local/clang-trunk/bin/clang-4.0+0x8a7828)
#15 0x00000000020bfd25 (anonymous
namespace)::ScalarExprEmitter::Visit(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-4.0+0x20bfd25)
#16 0x00000000020c0923
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x20c0923)
#17 0x000000000207129c
clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*,
clang::ValueDecl const*, clang::CodeGen::LValue, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x207129c)
#18 0x0000000002071ea3
clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*,
clang::ValueDecl const*, clang::CodeGen::LValue, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2071ea3)
#19 0x0000000002072e71
clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission
const&) (/usr/local/clang-trunk/bin/clang-4.0+0x2072e71)
#20 0x0000000002078122
clang::CodeGen::CodeGenFunction::EmitAutoVarDecl(clang::VarDecl const&)
(/usr/local/clang-trunk/bin/clang-4.0+0x2078122)
#21 0x0000000001f3678f
clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1f3678f)
#22 0x0000000001f42b12
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*)
(/usr/local/clang-trunk/bin/clang-4.0+0x1f42b12)
#23 0x0000000001f3ecd8 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*) (/usr/local/clang-trunk/bin/clang-4.0+0x1f3ecd8)
#24 0x0000000001f3fb3f
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/usr/local/clang-trunk/bin/clang-4.0+0x1f3fb3f)
#25 0x0000000001f66472
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*) (/usr/local/clang-trunk/bin/clang-4.0+0x1f66472)
#26 0x0000000001f712a6
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1f712a6)
#27 0x0000000001f925c1
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-4.0+0x1f925c1)
#28 0x0000000001fa3e21
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-4.0+0x1fa3e21)
#29 0x0000000001fa4d41
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/usr/local/clang-trunk/bin/clang-4.0+0x1fa4d41)
#30 0x0000000001fa5461
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) [clone
.part.6356] (/usr/local/clang-trunk/bin/clang-4.0+0x1fa5461)
#31 0x00000000025305fb (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/usr/local/clang-trunk/bin/clang-4.0+0x25305fb)
#32 0x000000000252addc
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/usr/local/clang-trunk/bin/clang-4.0+0x252addc)
#33 0x0000000002894ea6 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2894ea6)
#34 0x000000000252b8fe clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-4.0+0x252b8fe)
#35 0x0000000002236efe clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-4.0+0x2236efe)
#36 0x000000000220c6f6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x220c6f6)
#37 0x00000000022c4572
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-4.0+0x22c4572)
#38 0x0000000000b1cb88 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-4.0+0xb1cb88)
#39 0x0000000000acb577 main (/usr/local/clang-trunk/bin/clang-4.0+0xacb577)
#40 0x00007ffca23c2ec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#41 0x0000000000b18bb4 _start (/usr/local/clang-trunk/bin/clang-4.0+0xb18bb4)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-4.0 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb
-coverage-file /data2/small.cpp -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/4.0.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/4.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /data2 -ferror-limit 19 -fmessage-length 248
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o small.o -x c++ small.cpp
1.      <eof> parser at end of file
2.      small.cpp:1:6: LLVM IR generation of declaration 'f'
3.      small.cpp:1:6: Generating code for declaration 'f'
clang-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (trunk 276243)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-4.0: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-4.0: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-4.0: note: diagnostic msg: /tmp/small-297793.cpp
clang-4.0: note: diagnostic msg: /tmp/small-297793.sh
clang-4.0: note: diagnostic msg:

********************
$


--------------------------------------


void f ()
{ 
  bool b = __builtin_signbit (f);
}

-- 
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/20160721/58c722da/attachment-0001.html>


More information about the llvm-bugs mailing list