title: First insert into a static STL set causes Unhandled exception 0xC0000005: Access violation to be thrown
body: <p>so I am working in VS 2008 with C++ for an embedded environment(ARM processor). I've built a medium sized project for my company. It has thus far been a windows application. I was asked to change it to a console application because that makes more sense for this application. I had no real reason for making it a windows application... At first, I just changed the appropriate settings (I think) in VS and then rebuilt. It built fine, but then I got the exception quoted in the title each time I tried to run the program. I want to emphasize that the program was working perfectly before I switched it to a console application. I did do a full clean and rebuild of the entire solution as well.</p>
  
  <p>I thought that this was probably just a problem with me manually changing the settings, so I made a new project that was set to be a console app and plugged all of the source/other associated projects into that. This builds fine as well once I got all of the different projects in the solution linked together correctly, but the same error comes up.</p>
  
  <p>When the program crashes, it stops at the insert command in the following method:</p>
  
  <pre><code>template&lt;class Elem&gt;
  Node&lt;Elem&gt;* Node&lt;Elem&gt;::addChild(const Elem&amp; value)
  {
      Node&lt;Elem&gt;* newNode = new Node(value);
      newNode-&gt;m_pParentNode = this;
      m_childList.push_back(newNode);
      m_sNodeSet.insert(newNode);
      return newNode;
  }
  </code></pre>
  
  <p>The m_sNodeSet is there to enforce the rule that each node in the tree must be unique. The error occurs the first time that this addChild method is called. At this time, the m_sNodeSet is of size zero and needs to allocate some memory. But the exception thrown is Access Violation, not Bad Alloc as might be expected. I did try adding a m_sNodeSet.get_allocator().allocate(5) before the insert statement to see if that would do anything, but the same exception is thrown. The m_sNodeSet is a static member variable, if that makes a difference.</p>
  
  <p>This Node class is a custom tree object I have created. I have not changed anything in this tree project for weeks and it has been working fine. I don't think that I am throwing anything at this tree project that it hasn't seen before and performed perfectly with, so I don't think the problem lies with the tree project itself.</p>
  
  <p>I am certain that this is not an issue of accessing STL containers across library boundaries  either. This error is occurring within the operations of a single static library.</p>
  
  <p>I feel like there must be some setting that still needs to be changed in my solution to make this work properly. There are several projects in the solution, one DLL, one LIB, and one EXE. The tree is a fourth project, but that one is simply put into the appropriate projects' "additional includes." I only changed the EXE so that it would execute as a console app. </p>
  
  <p>If you all have any inklings on what could be the problem here it would be much appreciated.</p>