title: VS2010 C code - String pooling
body: <p>Below code crash in VS 2010 when you compile with following flag and if you add /GF- or remove the opimization flag they don't crash. The crash occur at assembly code which translate 'if( path[i] == '/' )'. I like to understand the optimization that compiler does here and lead to crash. Looking forward for some pointers.</p>
  
  <p>-Karthik</p>
  
  <p><code>cl.exe /MD /O2 test.c</code></p>
  
  <p><code>//</code> Test.c</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  #include  &lt;string.h&gt;
  
  void testpath(char* path, int bufsiz)  
  {  
  
      int i;  
  
      printf("%p\n", path);  
      for( i=0; i &lt; strlen(path); i++ ) {  
        if( path[i] == '/' ) {  
           path[i] = '\\';  
       }  
    }  
  }
  
  int main()  
  {  
  
      const char* path = "testexport.prj";  
      char *path1 = "testexport.prj";  
      printf("%p\n", path);  
      printf("%p\n", path1);  
      testpath(path, 1024);  
  }  
  </code></pre>