int k = (int *)arg;this statement can not compaile with G++,But GCC only Warning,why?
It doesn’t compile in C++ because int* is not implicitly convertible to int and therefore the statement is ill-formed.
// int k=*(int *)arg;why this statement not right?
That statement is syntactically well-formed in C++. But arg doesn’t point to an int object (or object of compatible type), so the behaviour of indirecting through the pointer is undefined.
solved GCC/G++ different attitudes for: void* to int [closed]