title: Strange access violation at vector indexer
body: <p>At first some introductions: I am currently working on a C++ compatibility thing which means being able to run projects with different compiler options with each other. Therefore I test with a Release DLL and a Debug application linking to that other project.
  Most of the problems come up when using STL so I have to assure that both projects only use their own version of the STL.
  Thatswhy I have a wrapper class that can be build out of std::vectors, std::lists and so on but contains only an array which is completely compatible. Now I can wrap values in an array and unpack them on the other side into a valid STL object.</p>
  
  <p>Now to get a bit closer to the question: There are some classes that contain STL but also need to be wrapped into an array. So I have to wrap the inner STL object, too, which means adding a <em>tag</em> and saving it right next to the associated array element.</p>
  
  <p>Building up this wrapper class is no problem at all but unpacking it crashes with an access violation in the vector class right here:</p>
  
  <pre><code>   const_reference operator[](size_type _Pos) const
          {   // subscript nonmutable sequence
  
   #if _HAS_ITERATOR_DEBUGGING
          if (size() &lt;= _Pos)
              {
              _DEBUG_ERROR("vector subscript out of range");
              _SCL_SECURE_OUT_OF_RANGE;
              }
   #endif /* _HAS_ITERATOR_DEBUGGING */
          _SCL_SECURE_VALIDATE_RANGE(_Pos &lt; size());
  
          return (*(_Myfirst + _Pos));  &lt;---- HERE
          }
  </code></pre>
  
  <p>The executing code at that moment is this:</p>
  
  <pre><code>template&lt;class T&gt;
  struct mwContainerItem
  {
      T m_element;
      void * m_tag;
  };
  
  template&lt;class T&gt;
  class mwContainer
  {
      STLList ToList()
      {
          STLList l;
          for(size_t i=0; i&lt;m_size; ++i) &lt;---- It crashes when accessing m_size
          {
              l.push_back(m_elements[i].m_element); &lt;---- It also crashes when accessing m_elements
          }
          return l;
      }
  
      mwContainerItem&lt;T&gt;* m_elements;
      size_t m_size;
  };
  </code></pre>
  
  <p>The curious thing about it is I'm unpacking a std::list but it crashes in std::vector. Viewing at the whone thing I have a class contained by a std::vector and this very class contains a std::list of some basic class without STL. So unpacking means copying the outer array into a std::vector and every inner array into a std::list.</p>
  
  <p>This error only occurs when I use the different compiler options, packing und unpacking in the very same project works just fine.</p>
  
  <p>I really hope that anyone can help me cause I don't have any idea.</p>
  
  <p>Regards</p>