fixed bug for typecasting ptr -> int.