[PATCH] Assertion when incomplete array type is used as template param

jyoti allur jyoti.yalamanchili at gmail.com
Wed Sep 18 23:48:04 PDT 2013

jyoti.yalamanchili added you to the CC list for the revision "Assertion when incomplete array type is used as template param".

Hi dblaikie, rsmith,


Following assertion occurs for the test code mentioned below. 

assert(!isIncompleteType() && "This doesn't make sense for incomplete types");

Test code :-
// { dg-options "-std=c++0x" }
template<class T>
T&& create();
template<class T, class... Args>
void test() {
  T t(create<Args>()...);	// { dg-error "incomplete" }
  (void) t;
int main() {

since int[] is incomplete type, it is not valid to call isConstantSizeType() on such types.

I have added a check to prevent checking constant size if type is incomplete array type, as incomplete types do not have known constant size.
let me know your review comments.




Index: CGDecl.cpp
--- CGDecl.cpp
+++ CGDecl.cpp
@@ -839,7 +839,7 @@
   llvm::Value *DeclPtr;
-  if (Ty->isConstantSizeType()) {
+  if (!Ty->isIncompleteArrayType() && Ty->isConstantSizeType()) {
     bool NRVO = getLangOpts().ElideConstructors &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1700.1.patch
Type: text/x-patch
Size: 381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130918/63d362ea/attachment.bin>

More information about the cfe-commits mailing list