I'm porting a huge application from PowerPC to ARM. I'd decided to use gcc option -Wcast-align
to detect the instances that might cause alignment issues.
But then, I thought about a situation that the -Wcast-align
option won't detect.
Eg:
typedef struct sample_s {
uint8_t c;
double i;
} __attribute__((packed)) sample_t;
void main ( void ) {
double *i;
sample_t check;
check.i = 2;
i = &check.i;
printf("i= %a\n", *i);
}
ARM will raise an alignment exception for the above code, but -Wcast-align
won't report this.
Is there any other way to detect such instances?