Ben Elliston wrote: > This patch silences the following warnings when building libgcc: > > unwind-dw2-fde.c:321: warning: dereferencing type-punned pointer will break > strict-aliasing rules
> - const _Unwind_Ptr x_ptr = *(const _Unwind_Ptr *) x->pc_begin; > - const _Unwind_Ptr y_ptr = *(const _Unwind_Ptr *) y->pc_begin; > + _Unwind_Ptr x_ptr, y_ptr; > + memcpy (&x_ptr, x->pc_begin, sizeof (_Unwind_Ptr)); > + memcpy (&y_ptr, y->pc_begin, sizeof (_Unwind_Ptr)); Say, I've been in the habit in the past (GCC 3.x) of avoiding these warnings by doing like: > - const _Unwind_Ptr x_ptr = *(const _Unwind_Ptr *) x->pc_begin; > - const _Unwind_Ptr y_ptr = *(const _Unwind_Ptr *) y->pc_begin; > + const _Unwind_Ptr x_ptr = *(const _Unwind_Ptr *) (void *) x->pc_begin; > + const _Unwind_Ptr y_ptr = *(const _Unwind_Ptr *) (void *) y->pc_begin; ... which I see no longer works. Was that ever correct, or was I just losing information during the cast-to-void that meant GCC just couldn't diagnose a potential problem, but it was still there? I believed that casting through void would make the result could-alias-anything, which I thought would prevent any untoward consequences. Also, maybe rather than warning, we could translate the assignment to a built-in memcpy internally? Or perhaps best of all do both? cheers, DaveK