Use push_back rather than operator[], which is incorrect in this cases. Unfortunately...
authorOwen Anderson <resistor@mac.com>
Wed, 25 Jun 2008 01:05:05 +0000 (01:05 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 25 Jun 2008 01:05:05 +0000 (01:05 +0000)
but only marginally.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52700 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Constants.cpp

index 39c0a8c70107f5c551f574db91eee3e6449cef88..b9976a72070a59022701dc29f0d5a91e38cd28aa 100644 (file)
@@ -1380,7 +1380,7 @@ std::string ConstantArray::getAsString() const {
   std::string Result;
   Result.reserve(getNumOperands());
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
-    Result[i] = (char)cast<ConstantInt>(getOperand(i))->getZExtValue();
+    Result.push_back((char)cast<ConstantInt>(getOperand(i))->getZExtValue());
   return Result;
 }