title: Why does VS clam this violates memory?
body: <p>I needed to enforce some SSE memory boundaries for the code i'm writing but i'm having some trouble with Visual Studio's memory checker. I'm wondering why VS believes there is memory getting corrupted?</p>
  
  <pre><code>#define sse_t float* __restrict
  #include &lt;iostream&gt;
  #include &lt;assert.h&gt;
  #include &lt;stdio.h&gt;
  using namespace std;
  class AlignedContainer {
  public:
      AlignedContainer(int n = 0, int frames = 0, size_t align = 16) {
  
          assert((align &amp; (align - 1)) == 0);
          int bufferSize = sizeof(float) * n;
          for (int i = 0; i &lt; frames; i++) {
              int alignedSize = bufferSize + 15;
              auto aqbuf = new unsigned char[alignedSize];
              auto aligned = reinterpret_cast &lt; unsigned char *&gt;((reinterpret_cast &lt; size_t &gt; (aqbuf) + 15) &amp; ~15); // 16 bit alignment in preperation for SSE
              memset(aqbuf, 0, alignedSize); // for debugging, forces memory to instantly allocate
              AcqBuffers.push_back(aqbuf);
              displayFrames.push_back(aligned);
          }
      }
  
      ~AlignedContainer() {
              for (int i = 0; i &lt; AcqBuffers.size(); i++) {
                  delete[]AcqBuffers[i];
              }
              AcqBuffers.empty();
              displayFrames.empty();
          }
  
  inline sse_t operator [] (int i) const {
          return (sse_t) displayFrames[i];
      }
  
  private:
          vector &lt; void *&gt;displayFrames;
          vector &lt; void *&gt;AcqBuffers;
  };
  
  int main(int argc, char *argv[])
  {
      int h = 2160;
      int w = 2544;
      AlignedContainer ac;
      ac = AlignedContainer(h * w, 4);
  }
  </code></pre>
  
  <p>Error at the last line.</p>
  
  <pre><code>/***
  *static int CheckBytes() - verify byte range set to proper value
  *
  *Purpose:
  *       verify byte range set to proper value
  *
  *Entry:
  *       unsigned char *pb       - pointer to start of byte range
  *       unsigned char bCheck    - value byte range should be set to
  *       size_t nSize            - size of byte range to be checked
  *
  *Return:
  *       TRUE - if all bytes in range equal bcheck
  *       FALSE otherwise
  *
  *******************************************************************************/
  extern "C" static int __cdecl CheckBytes(
          unsigned char * pb,
          unsigned char bCheck,
          size_t nSize
          )
  {
          while (nSize--)
          {
              if (*pb++ != bCheck)
              {
                  return FALSE;
              }
          }
          return TRUE;
  }
  </code></pre>