llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.04k stars 11.58k forks source link

-disable-checker causes assert #22578

Open llvmbot opened 9 years ago

llvmbot commented 9 years ago
Bugzilla Link 22204
Version 3.4
OS Linux
Reporter LLVM Bugzilla Contributor
CC @belkadan

Extended Description

I found this problem using clang 3.4 and checker-276. I have just checked to see if the problem still occurs with a trunk build of llvm + clang and it does.

ex.cpp - contains a divide by zero error

int main() { int i = 0; return 1/i; }

As soon as you try and disable the relevant core checker the static analyzer asserts

$HOME/llvm-20150112/tools/clang/tools/scan-build/scan-build --use-analyzer=$HOEM/llvm-20150112-build/Release+Asserts/bin/clang --use-c++=$HOME/llvm-20150112-build/Release+Asserts/bin/clang -disable-checker core.DivideZero clang -g -o ex ex.cpp

clang: /vault/home/adrian.swain/llvm-20150112/lib/Support/APInt.cpp:1866: llvm::APInt llvm::APInt::udiv(const llvm::APInt&) const: Assertion `RHS.VAL != 0 && "Divide by zero?"' failed.

llvmbot commented 2 years ago

mentioned in issue llvm/llvm-bugzilla-archive#22205

belkadan commented 9 years ago

The analyzer's not meant to run with any of the core checkers disabled. It really has no way to represent a state in which a division-by-zero has occurred and the program has /not/ crashed. The same applies to most of the other core checkers.

One thing that could be done here is a refactoring so that turning off the core checker only turns off the output, not the path pruning, but without further information I can't say whether that will actually solve your problem.

llvmbot commented 9 years ago

Bug llvm/llvm-bugzilla-archive#22205 has been marked as a duplicate of this bug.

llvmbot commented 9 years ago

assigned to @tkremenek