[cfe-dev] signess error when building cfg

Eli Friedman eli.friedman at gmail.com
Thu Jul 3 18:43:11 PDT 2008


On Thu, Jul 3, 2008 at 2:13 PM, Jean-Daniel Dupas
<devlists at shadowlab.org> wrote:
> Hello,
>
> I just encounter an assert when performing file analysis (cfg-building) in
> clang::Expr::isIntegerConstantExpr()
>
> When I perform an operation between to variable with different sign, APSInt
> raise an error (assert).
>
> And so, something like 'clang -cfg-dump' on this code will crash:
>
> #include <stdint.h>
>
> void testBinaryOp() {
>  void *bytes = 0;
>  /* Alignement */
>  bytes = (intptr_t)bytes + 2;
>  bytes = (intptr_t)bytes % 2;
>  bytes = (intptr_t)bytes / 2;
> }
>
>
> Is it a known issue, or is it worth filling a bug report ?
>
> Stack trace:
>
> #4  0x91ca9063 in __assert_rtn ()
> #5  0x00028789 in llvm::APSInt::operator+= (this=0xbfffe5b0,
> RHS=@0xbfffe454) at APSInt.h:159
> #6  0x00025fd9 in clang::Expr::isIntegerConstantExpr (this=0xc0ae30,
> Result=@0xbfffe5b0, Ctx=@0xbfffef80, Loc=0x0, isEvaluated=true) at
> /Users/Projects/Tools/llvm/tools/clang/lib/AST/Expr.cpp:876

Mmm, if I'm not mistaken, this looks like a known issue with the hack
allowing pointers in integer constant expressions; I was planning to
fix it sooner, but the right fix grew a bit bigger than I expected it
to, and I never got around to coming up with a quick hack.
(Specifically, the complete fix involves the new constant expression
evaluator work.)

-Eli



More information about the cfe-dev mailing list