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

jyoti allur jyoti.yalamanchili at gmail.com
Wed Sep 18 23:32:26 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,

Hello,

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() {
  test<int[]>();
}


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.

Thanks.

http://llvm-reviews.chandlerc.com/D1700

Files:
  CGDecl.cpp

Index: CGDecl.cpp
===================================================================
--- CGDecl.cpp
+++ CGDecl.cpp
@@ -839,7 +839,7 @@
     EmitVariablyModifiedType(Ty);
 
   llvm::Value *DeclPtr;
-  if (Ty->isConstantSizeType()) {
+  if (!Ty->isIncompleteArrayType() && Ty->isConstantSizeType()) {
     bool NRVO = getLangOpts().ElideConstructors &&
       D.isNRVOVariable();
-------------- 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/llvm-commits/attachments/20130918/0a67e3a2/attachment.bin>


More information about the llvm-commits mailing list