[cfe-dev] Expr::isIntegerConstantExpr() gives bogus results with sizeof()
Ted Kremenek
kremenek at apple.com
Sun Nov 25 19:14:58 PST 2007
On Nov 25, 2007, at 9:48 AM, Chris Lattner wrote:
>
> 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
Should the fix instead go in the body of getTypeSize() instead of
within isConstantExpr()? Should getTypeSize() ever return the number
of bits instead of the number of bytes? Does this have something to
do with bitfields?
More information about the cfe-dev
mailing list