[cfe-dev] Expr::isIntegerConstantExpr() gives bogus results with sizeof()

Chris Lattner clattner at apple.com
Sun Nov 25 09:48:34 PST 2007


On Nov 25, 2007, at 9:39 AM, Nuno Lopes wrote:

> Hi,
>
> Expr::isIntegerConstantExpr() seems to return bogus results with the
> sizeof() operator.
> For example, for input "21-2*2+4", it returns 21 as expected
> but with sizeof:
>
> int buf_src[4];
> sizeof(buf_src) => 128 (4 * 4 * 8 bits)
> sizeof(buf_src)-sizeof(buf_src)/sizeof(*buf_src) => 124 (???)
>
> So it seems that sizeof() is being computed in bits, but then the
> operations aren't consistent. (in fact it should be computed in bytes,
> as that's the value of that operator in C/C++)

Yep, you're right, applied, thanks!

-Chris




More information about the cfe-dev mailing list