Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Assertion failed: (E->isRValue() && E->getType()->hasPointerRepresentation()), function EvaluatePointer, file tools/clang/lib/AST/ExprConstant.cpp, line 4489 #16726

Closed Quuxplusone closed 11 years ago

Quuxplusone commented 11 years ago
Bugzilla Link PR16727
Status RESOLVED FIXED
Importance P normal
Reported by Dimitry Andric (dimitry@andric.com)
Reported on 2013-07-28 15:41:58 -0700
Last modified on 2013-08-19 17:06:27 -0700
Version trunk
Hardware All All
CC efriedma@quicinc.com, llvm-bugs@lists.llvm.org, rafael@espindo.la, richard-llvm@metafoo.co.uk, rtrieu@google.com, wlodzimierz.lipert@gmail.com
Fixed by commit(s)
Attachments rvalue-haspointerrep-assert.tar.xz (1014064 bytes, application/x-xz)
Blocks
Blocked by
See also
Created attachment 10946
Testcase for isRValue && hasPointerRepresentation assert

This is an assert encountered while compiling a certain file of the FreeBSD
port lang/sdcc (Small Device C Compiler, see http://sdcc.sourceforge.net/ ):

$ clang++ -c SDCClospre-a1f812.cpp
Assertion failed: (E->isRValue() && E->getType()->hasPointerRepresentation()),
function EvaluatePointer, file
/share/dim/src/llvm/trunk/tools/clang/lib/AST/ExprConstant.cpp, line 4489.
Stack dump:
0.      Program arguments: /share/dim/llvm/187332-trunk-freebsd10-amd64-aconf-
rel-1/bin/clang -cc1 -triple x86_64-unknown-freebsd10.0 -emit-obj -mrelax-all -
disable-free -main-file-name SDCClospre-a1f812.cpp -mrelocation-model static -
mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-
cpu x86-64 -target-linker-version 2.23.2 -coverage-file
/share/dim/src/llvm/bugs/rvalue/SDCClospre-a1f812.o -resource-dir
/share/dim/llvm/187332-trunk-freebsd10-amd64-aconf-rel-1/bin/../lib/clang/3.4 -
fdeprecated-macro -fdebug-compilation-dir /share/dim/src/llvm/bugs/rvalue -
ferror-limit 19 -fmessage-length 154 -mstackrealign -fobjc-runtime=gnustep -
fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-
show-option -fcolor-diagnostics -vectorize-loops -o SDCClospre-a1f812.o -x c++
SDCClospre-a1f812.cpp
1.      ./SDCClospre.hpp:669:122: current parser token ')'
2.      ./SDCClospre.hpp:628:1: parsing function body
'implement_lospre_assignment'
3.      ./SDCClospre.hpp:628:1: in compound statement ('{}')
4.      ./SDCClospre.hpp:663:5: in compound statement ('{}')
clang: error: unable to execute command: Abort trap (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.4 (trunk ^/cfe/trunk 187332)
Target: x86_64-unknown-freebsd10.0
Thread model: posix
clang: 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: note: diagnostic msg:
********************

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

********************

Because attempting to reduce the file does not work (the error is not triggered
anymore, or clang crashes on something else), I will attach the full testcase.
Quuxplusone commented 11 years ago

Attached rvalue-haspointerrep-assert.tar.xz (1014064 bytes, application/x-xz): Testcase for isRValue && hasPointerRepresentation assert

Quuxplusone commented 11 years ago
Repro:
template<class Foo>
bool test(Foo f, int *array)
{
  return false && false || array[f.get()];
}

One of the -Wparentheses warnings is trying to see if "array[f.get()]" is a
constant value, but one of the constant expression evaluators is choking on the
dependent expression.

llvm/tools/clang/lib/AST/ExprConstant.cpp:4489: bool EvaluatePointer(const
clang::Expr*, {anonymous}::LValue&, {anonymous}::EvalInfo&): Assertion `E-
>isRValue() && E->getType()->hasPointerRepresentation()' failed.

#4  0x00000000016a23c0 in EvaluatePointer (E=0x440c318, Result=..., Info=...)
    at llvm/tools/clang/lib/AST/ExprConstant.cpp:4489
#5  0x00000000016a1a94 in (anonymous
namespace)::LValueExprEvaluator::VisitArraySubscriptExpr (this=0x7fffffff9db0,
E=0x440c340) at llvm/tools/clang/lib/AST/ExprConstant.cpp:4346
Quuxplusone commented 11 years ago

_Bug 16930 has been marked as a duplicate of this bug._

Quuxplusone commented 11 years ago

Fixed in r188716.