Changing elements of a constant char* literal in VS
<p>This is the code:</p>

<pre><code>int main()  
{  
    char* a = "abc";    // Should be 'const char*', but no warnings whatsoever on VS
    a[1] = 'e';         // No warnings on VS either 

    std::cout&lt;&lt; a &lt;&lt; " " &lt;&lt; a[1];  

    return 0;  
} 
</code></pre>

<p><br><br>
Compiled using gcc version 6.2.0:  </p>

<pre><code>&gt;g++ -O2 -o Test Test.cpp
Test.cpp: In function ‘int main()’:
Test.cpp:5:15: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
 char* a = "abc";
           ^~~~~
</code></pre>

<hr>

<pre><code>&gt;./Test
Segmentation fault (core dumped)
</code></pre>

<p><br><br>
Compiled using VS 2015.3:  </p>

<pre><code>&gt;cl /EHsc /W4 /WX /O2 Main.cpp  
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86  
Copyright (C) Microsoft Corporation.  All rights reserved.  

Main.cpp  
Microsoft (R) Incremental Linker Version 14.00.24215.1  
Copyright (C) Microsoft Corporation.  All rights reserved.  

/out:Main.exe  
Main.obj   
</code></pre>

<hr>

<pre><code>&gt;Main.exe  
abc e  

HUH?^
</code></pre>

<p>Compiling without <code>/O2</code> yields no warnings either, but crashes on runtime.<br>
<br><br>
Is this a VS compiler bug or I'm missing something?  </p>