llvm / llvm-project

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

support addressing into a specific byte of a larger object #3192

Open llvmbot opened 16 years ago

llvmbot commented 16 years ago
Bugzilla Link 2820
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @tkremenek

Extended Description

[s002:165] [rwg@mini /tmp]% uname -a; svn info ~/llvm/llvm ~/llvm/llvm/tools/clang | grep Revision: Darwin mini.local 9.5.0 Darwin Kernel Version 9.5.0: Wed Sep 3 11:31:44 PDT 2008; root:xnu-1228.7.58~1/RELEASE_PPC Power Macintosh Revision: 56425 Revision: 56427 [s002:166] [rwg@mini /tmp]% cat t3.c int f() { short a = 1; return !(((char *)&a)[0]); }

[s002:167] [rwg@mini /tmp]% clang -x c t3.c

[s002:168] [rwg@mini /tmp]% clang -x c t3.c -checker-cfref ANALYZE: t3.c f Assertion failed: (BitWidth == RHS.BitWidth && "Comparison requires equal bit widths"), function operator==, file /Users/rwg/llvm/llvm/include/llvm/ADT/APInt.h, line 792. 0 clang 0x00492a7c _ZN4llvm3sys7Program17FindProgramByNameERKSs + 796 1 clang 0x00492e34 _ZN4llvm3sys28PrintStackTraceOnErrorSignalEv + 760 2 libSystem.B.dylib 0x96a836a4 _sigtramp + 68 3 clang 0x0047845c _ZN4llvm16FoldingSetNodeID10AddPointerEPKv + 64 zsh: abort clang -x c t3.c -checker-cfref

If you remove the "!" in the return statement, it doesn't throw the assertion failure.

The same assertion failure is seen on Debian 4.0/i386 with llvm r56423 / clang r56415.

llvmbot commented 5 years ago

Devin, is this still relevant?

tkremenek commented 15 years ago

It looks like this problem was addressed sometime in the past year -- I no longer get the assertion failure w/ r81189 on Linux/x86_64.

Should this bug be closed?

The crash no longer occurs, but the analyzer still isn't doing the right thing w.r.t. to handling the byte load from a larger integer/object.

llvmbot commented 15 years ago

It looks like this problem was addressed sometime in the past year -- I no longer get the assertion failure w/ r81189 on Linux/x86_64.

Should this bug be closed?

tkremenek commented 16 years ago

This is the same bug as:

rdar://problem/6151550 support addressing into a specific byte of a larger object

The problem is that we don't correctly handle the EvalLoad into a specific byte of a larger integer. EvalLoad should not assume that we're loading the entire specified object.

This bug will get fixed once more of the support for abstract "regions" is in place and we can handle offsets into regions. We will then have to reason about the endianness of the system to support the correct byte loads from a larger integer value.

lattner commented 16 years ago

Is this a bug in the checker or in clang?

llvmbot commented 16 years ago

assigned to @devincoughlin