This code behaves weird in MS Visual Studio:
char *s = "hello";
s[0] = 'a';
printf(s);
In release build with optimization turned on it ignores s[0] = 'a' and prints "hello". Without optimization or in debug build it crashes with access violation.
Is this behavior is c++ standard compliant or no? In my opinion, compiler should only allow constant references to string literals, i.e.
const char *s = "hello";
EDIT: I know why it works like this, I do not understand why I am allowed to make non const reference to read only memory.