[cfe-dev] ConstantArrayType's size is not always of pointer width

Eli Friedman eli.friedman at gmail.com
Tue Dec 2 10:54:17 PST 2008


On Tue, Dec 2, 2008 at 9:03 AM, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
> Eli Friedman wrote:
>>
>> On Tue, Dec 2, 2008 at 8:51 AM, Sebastian Redl
>> <sebastian.redl at getdesigned.at> wrote:
>>
>>>
>>> Hmm ... looking at the code that creates the type (SemaType.cpp:391),
>>> the array size is in fact always 32 bits wide. This definitely looks
>>> like a bug.
>>>
>>
>> No, it's not; it's just using the width of the constant for the array
>> size; isIntegerConstantExpr overwrites the given width.
>>
>
> Ah, OK. But is using the width of the constant the right thing to do?
> Shouldn't an array size ultimately be of type size_t?

It'll ultimately be allocated that way, but casting doesn't really
seem necessary; we definitely don't want to truncate the size.

-Eli



More information about the cfe-dev mailing list