>>> 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?

This is the right solution.  We want getTypeSize to be unambiguous as  
to units, and bits are the most constant thing there are.  Various  
strange things like bitfields, non-8-bit-bytes, and datatypes that are  
not even multiples of byte sizes all conspire to wanting to have a  
simple and unambiguous unit to represent things in, bits is the right  
way to go.

sizeof, on the other hand, is determined in units of sizeof(char).  To  
be fully general, it shouldn't divide by 8, it should divide by  
TargetInfo.getCharSize().

-Chris 
   
_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

Reply via email to