Some compilers are picky about accessing the first element of a std::vector if
authorBill Wendling <isanbard@gmail.com>
Thu, 1 Jan 2009 01:14:31 +0000 (01:14 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 1 Jan 2009 01:14:31 +0000 (01:14 +0000)
there's nothing in the vector. Pacify them.

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

include/llvm/CodeGen/ScheduleDAGSDNodes.h

index d7f0ea49d487de3f46d53a56c1d3b4fc98578646..b9c6428fba7bca233348f835f6daaa283b09992d 100644 (file)
@@ -103,10 +103,13 @@ namespace llvm {
     ///
     SUnit *NewSUnit(SDNode *N) {
 #ifndef NDEBUG
-      const SUnit *Addr = &SUnits[0];
+      const SUnit *Addr = 0;
+      if (SUnits.size() > 0)
+        Addr = &SUnits[0];
 #endif
       SUnits.push_back(SUnit(N, (unsigned)SUnits.size()));
-      assert(Addr == &SUnits[0] && "SUnits std::vector reallocated on the fly!");
+      assert((Addr == 0 || Addr == &SUnits[0]) &&
+             "SUnits std::vector reallocated on the fly!");
       SUnits.back().OrigNode = &SUnits.back();
       return &SUnits.back();
     }