[cfe-dev] Assertion failure when a multidimensional array allocated with new operator is explicitly list initialized

Jyoti jyoti.yalamanchili at gmail.com
Thu Nov 7 05:39:07 PST 2013


Hi All,
I am trying to resolve an assertion failure that occurs for following test
code with latest llvm svn trunk code as well.

// PR c++/56772
// { dg-require-effective-target c++11 }

typedef __SIZE_TYPE__ size_t;
void* operator new[](size_t, void *p) { return p; }
//template <typename T = size_t>
void f ()
{
  size_t coord [3][3];
  new (&coord) size_t [3][3]
   {
     {0,0,0},
     {0,0,0},
     {0,0,0},
   };
}

int main ()
{
   //f<>();
   f();
}

It appears that storing subinitlist expressions is not taken care in
EmitNewArrayInitializer
check this code :-
for (unsigned i = 0, e = ILE->getNumInits(); i != e; ++i) {
      // Tell the cleanup that it needs to destroy up to this
      // element.  TODO: some of these stores can be trivially
      // observed to be unnecessary.
      if (endOfInit) Builder.CreateStore(explicitPtr, endOfInit);
      StoreAnyExprIntoOneUnit(*this, ILE->getInit(i), elementType,
explicitPtr);
      explicitPtr =Builder.CreateConstGEP1_32(explicitPtr, 1,
"array.exp.next");
    }

I had made a quick fix which was uploaded at
http://llvm-reviews.chandlerc.com/D1986
It is not a final solution, but i am hoping it is the right direction.
Could someone please provide me constructive inputs so that i know i am
heading in right direction.

Many Thanks!
Jyoti Allur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131107/96c74313/attachment.html>


More information about the cfe-dev mailing list