[cfe-commits] r89366 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/ASTContext.cpp lib/Sema/SemaInit.cpp test/SemaTemplate/dependent-sized_array.cpp

Douglas Gregor dgregor at apple.com
Thu Nov 19 13:01:31 PST 2009


On Nov 19, 2009, at 10:59 AM, John McCall wrote:

> Douglas Gregor wrote:
>> Author: dgregor
>> Date: Thu Nov 19 12:03:26 2009
>> New Revision: 89366
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=89366&view=rev
>> Log:
>> Cope with an amusingly little anomaly with dependent types and
>> incomplete array initialization, where we have the following in a
>> template:
>>
>>  int a[] = { 1, 2, something-value-dependent };
>>  // ...
>>  sizeof(a);
>>
>> The type of "a" appears to be a non-dependent IncompleteArrayType,  
>> but
>> treating it as such makes the sizeof(a) fail at template definition
>> time. We now correctly handle this by morphing the  
>> IncompleteArrayType
>> into a DependentSizedArrayType with a NULL expression, indicating  
>> that
>> its size has no corresponding expression (and, therefore, the type is
>> distinct from others).
>>
>
> Why does 'a' not just have a constant array type?  Why does the  
> value-dependence of the initializer affect the size at all?


Yeah, that's a good point. I was thinking about non-C++ messiness like  
designated initializers (which can make the size of the array >> the  
number of initializers) and C++0x pack expansions... but both of those  
should make the initializer list type-dependent. I'll take those into  
account in a revised fix...

	- Doug



More information about the cfe-commits mailing list