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

Eric Christopher echristo at gmail.com
Wed Sep 18 23:40:16 PDT 2013


This should probably go to cfe-commits, not llvm-commits.

Thanks!

-eric

On Wed, Sep 18, 2013 at 11:32 PM, jyoti allur
<jyoti.yalamanchili at gmail.com> wrote:
> 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();
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



More information about the llvm-commits mailing list