]> granicus.if.org Git - clang/commitdiff
PR20228: don't retain a pointer to a vector element after the container has been...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 23 Jul 2014 20:07:08 +0000 (20:07 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 23 Jul 2014 20:07:08 +0000 (20:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213790 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/type-traits.cpp

index 7fe5e7a4bfa6b1543c930b65d91506f3da9afc68..2745a8cbe3a491c57beba18033fd112746ff9b2f 100644 (file)
@@ -3651,12 +3651,13 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc,
       if (T->isObjectType() || T->isFunctionType())
         T = S.Context.getRValueReferenceType(T);
       OpaqueArgExprs.push_back(
-        OpaqueValueExpr(Args[I]->getTypeLoc().getLocStart(), 
+        OpaqueValueExpr(Args[I]->getTypeLoc().getLocStart(),
                         T.getNonLValueExprType(S.Context),
                         Expr::getValueKindForType(T)));
-      ArgExprs.push_back(&OpaqueArgExprs.back());
     }
-    
+    for (Expr &E : OpaqueArgExprs)
+      ArgExprs.push_back(&E);
+
     // Perform the initialization in an unevaluated context within a SFINAE 
     // trap at translation unit scope.
     EnterExpressionEvaluationContext Unevaluated(S, Sema::Unevaluated);
index 3b94ef0951ebff5e249bf798f026292f65284396..4833c14b30be5144315aa4666710efd0dc1f7c85 100644 (file)
@@ -146,6 +146,10 @@ struct ThreeArgCtor {
   ThreeArgCtor(int*, char*, int);
 };
 
+struct VariadicCtor {
+  template<typename...T> VariadicCtor(T...);
+};
+
 void is_pod()
 {
   { int arr[T(__is_pod(int))]; }
@@ -1968,6 +1972,10 @@ void constructible_checks() {
   // PR19178
   { int arr[F(__is_constructible(Abstract))]; }
   { int arr[F(__is_nothrow_constructible(Abstract))]; }
+
+  // PR20228
+  { int arr[T(__is_constructible(VariadicCtor,
+                                 int, int, int, int, int, int, int, int, int))]; }
 }
 
 // Instantiation of __is_trivially_constructible