Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

pointer to integer

What is "cast from integer to pointer of different size" warning?

Educative Answers Team

​Warnings are issued when the compiler compiles the code and finds something unusual that should be brought to the attention of the programmer.

svg viewer

The compiler issues the “cast from integer to pointer of different size” warning whenever the value of an integer is converted to a pointer, especially when the memory allocated to a pointer is smaller than the memory allocated to an integer data type. For example, if the pointers in a system are stored in 16 bits, but integers are stored in 8 bits, a total of 8 bits would be lost in the given conversion. Hence, a warning is ​issued.​

svg viewer
Data is lost upon conversion from a larger number (int) to a smaller number (pointer).


The following code shows this conversion:

int data = 999; // the integer  
int* pointer =  &data; // the pointer

pointer = data; // the conversion


pointer to integer
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring