I have some code that looks something like this:
void somefunc(uint64_t val) {
uint8_t *p;
uint8_t *s;
s = calloc( (max_sa_len + sizeof(uint64_t) - 1) / sizeof(uint64_t), sizeof(uint64_t));
p = (s + sizeof(uint64_t));
*(uint64_t)*p = hton64(val & 0xffff);
...
}
And when I compile, I get:
file.c:400:10: error: cast increases required alignment of target type [-Werror=cast-align]
Is there a clean way around this warning? s, and therefore pmust be aligned with 64-bit addresses, this is not a real mistake. I tried to add code p=__builtin_assume_alinged(p,8);to the code, but it did not fix the error. I get this error using arm32 (v7) gcc cross compiler, v 4.7.0
source
share