Suppress spurious -Wcast-align in the arena allocator#43
Conversation
|
can't repro |
cell_realloc()'s header-before-payload pattern and its call sites that cast the returned char* back to a wider-aligned pointer type trigger -Wcast-align under -Werror. The casts are safe: p is always either REALLOC()'s own return value, or p - sizeof(cell_t) recovers that exact same, maximally-aligned pointer -- the compiler just can't prove it from byte-level pointer arithmetic on a char*. Route each cast through an intermediate (void *), the standard idiom for a deliberate alignment-increasing cast. No behavioral change.
16c7299 to
51e6673
Compare
|
Re "can't repro": the warning only shows up if Steps to reproduce (against That fails with 8 Building the same command against this branch's I also rebased the branch onto the latest |
|
i don't see it on ubuntu... [cktan]% |
cell_realloc()'s header-before-payload pattern and its call sites that cast the returned char* back to a wider-aligned pointer type trigger -Wcast-align under -Werror. The casts are safe: p is always either REALLOC()'s own return value, or p - sizeof(cell_t) recovers that exact same, maximally-aligned pointer -- the compiler just can't prove it from byte-level pointer arithmetic on a char*. Route each cast through an intermediate (void *), the standard idiom for a deliberate alignment-increasing cast. No behavioral change.