[PATCH] D20511: Fix crash while parsing variable template with variadic template arguments

Olivier Goffart via cfe-commits cfe-commits at lists.llvm.org
Sat May 21 10:58:46 PDT 2016

ogoffart created this revision.
ogoffart added reviewers: cfe-commits, rsmith.

It is only a crash if the compiler optimize for this!=nullptr because
LocalInstantiationScope::getPartiallySubstitutedPack checks if 'this' is null.

(This is crashing when clang is compiled with GCC6)



Index: test/SemaCXX/cxx1y-variable-templates_top_level.cpp
--- test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -458,3 +458,9 @@
   template<> int g<double>; // expected-error {{no variable template matches specialization; did you mean to use 'g' as function template instead?}}
+#ifndef PRECXX11
+template <typename... Args> struct Variadic_t { };
+template <typename... Args> Variadic_t<Args...> Variadic;
+auto variadic1 = Variadic<>;
+auto variadic2 = Variadic<int, int>;
Index: lib/Sema/SemaTemplateVariadic.cpp
--- lib/Sema/SemaTemplateVariadic.cpp
+++ lib/Sema/SemaTemplateVariadic.cpp
@@ -604,7 +604,7 @@
     //   Template argument deduction can extend the sequence of template 
     //   arguments corresponding to a template parameter pack, even when the
     //   sequence contains explicitly specified template arguments.
-    if (!IsFunctionParameterPack) {
+    if (!IsFunctionParameterPack && CurrentInstantiationScope) {
       if (NamedDecl *PartialPack 
                     = CurrentInstantiationScope->getPartiallySubstitutedPack()){
         unsigned PartialDepth, PartialIndex;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20511.58043.patch
Type: text/x-patch
Size: 1312 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160521/19d5fa7a/attachment.bin>

More information about the cfe-commits mailing list