Я уверен, что следующий код не должен компилироваться. Но в g++ он компилируется! Посмотрите, как он компилируется на http://codepad.org/MR7Dsvlz .
Код:
#include
using namespace std;
int main() {
int x = 32 ;
// note: if x is, instead, a const int, the code still compiles,
// but the output is "32".
const int * ptr1 = & x ;
*((int *)ptr1) = 64 ; // questionable cast
cout << x ; // result: "64"
}
Ошибается ли g++, компилируя это?