Compiler Bug?
I ran into a warning for one section of code that I did not for a different section of code. So I simplified it into two function. I don't see why I get a warning for one and not the other.
void test32(uint32_t *data) {
uint32_t src_addr = (uint32_t) data;
}
void test16(uint16_t *data) {
uint16_t src_addr = (uint16_t) data;
}The compiler complains (also about unused variables, but I removed those)
../Core/Src/main.c: In function 'test16':
../Core/Src/main.c:161:22: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
161 | uint16_t src_addr = (uint16_t) data;
| ^
The compiler appears to be based on gcc 9.3.1.
If I put these two functions in a simple C file and build it on straight Linux (gcc 9.3.0) the warning exists for both instances.
main.c: In function ‘test16’:
main.c:15:23: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
15 | uint16_t src_addr = (uint16_t) data;
| ^
main.c: In function ‘test32’:
main.c:20:23: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
20 | uint32_t src_addr = (uint32_t) data;
| ^
