Type cast should not be used to turn a pointer to one type of structrure or data type in to another. The code actually worked fine because the integer values in use are all small. XLC 16.1 for AIX xlclang/xlclang++ error: cast to 'char *' from smaller ... cast __m256i to int - Intel Communities The size of pointers in general are not guaranteed to be anything.A char* could be a different size than an int*.A void* is guaranteed to be castable to other pointer types (AFAICR), so it follows that a void* should be no smaller than the largest of any other type of pointer's significant bits. Warning: You can call @truncate () on signed integers, but you need to make sure that's really what you want to do - since @truncate . For the compiler it is ok. Converting Long to int - Programming Questions - Arduino Forum Number Type Cast - Qt Forum [asahilinux:bits/070-audio 15/20] sound/soc/codecs/tas2764.c:683:20 ... 0 Kudos Copy link. In the expression dynamic_cast<T>(v), v is the expression to be cast, and T is the type to which it should be cast. The following code has unexpected (to me) behavior : int counter = 0; uint32_t longcounter = 0; void loop() { counter = counter + 5; longcounter = counter *1000; } This works fine until the 'counter' reaches 30. with the next addition of 5 the 'longcounter' will get a -30536 value. If you want to not add an extra compilation flag due to the fact that you might be upcasting an int to a void* accidentally somewhere else, you can use the following snippet to force a cast from an int to a void* where you are sure you want it to happen and then the compiler won't bug you about the cast: This is called widening typecasting. For example, if you want to store a 'long' value into a simple integer then you can type cast 'long' to 'int'.