[cfe-commits] [PATCH] Fix copy-list-initialization in template instantiation.

Richard Smith richard at metafoo.co.uk
Tue Dec 18 17:50:17 PST 2012


On Mon, Dec 17, 2012 at 5:28 AM, Olivier Goffart <ogoffart at kde.org> wrote:
> On Monday 10 December 2012 10:44:37 Olivier Goffart wrote:
>> Hi,
>>
>> Attached you will find a suggested fix for
>> http://llvm.org/bugs/show_bug.cgi?id=14486 and
>> http://llvm.org/bugs/show_bug.cgi?id=13470
>
> Ping?

+  if (VDecl->isInvalidDecl()) {
+  } else if (DirectInit && isa<CXXConstructExpr>(Init)) {
+      //We already have performed the initialisation
+      assert(cast<CXXConstructExpr>(Init)->getType() == DclT);

This doesn't look correct; the Init could be a CXXTemporaryObjectExpr.

+    if (getLangOpts().CPlusPlus0x && !DirectInit && isa<InitListExpr>(Init)
+        && !isa<InitListExpr>(Result.get())) {
+        // Remember this was a copy-list-initialization
+        VDecl->setInitStyle(VarDecl::ListInit);

This isn't acceptable: ListInit means direct-list-initialization.

     //       source type is the same class as, or a derived class of, the
     //       class of the destination, constructors are considered. [...]
     if (Kind.getKind() == InitializationKind::IK_Direct ||
+        Kind.getKind() == InitializationKind::IK_DirectList ||
         (Kind.getKind() == InitializationKind::IK_Copy &&
          (Context.hasSameUnqualifiedType(SourceType, DestType) ||
           S.IsDerivedFrom(SourceType, DestType))))

This looks wrong: list initialization is handled by the first bullet
of [dcl.init]p17, and this is the seventh bullet. We should never get
here for list initialization.

I've fixed this a different way in r170489.



More information about the cfe-commits mailing list