diff mbox series

[alpha] : Avoid warning: assignment to ‘struct sigcontext *’ from incompatible pointer type ‘mcontext_t *’

Message ID CAFULd4bU9C4=utJvG9hfWJsOJmTMcjyLkESHA71VU6i=VF9aAA@mail.gmail.com
State New
Headers show
Series [alpha] : Avoid warning: assignment to ‘struct sigcontext *’ from incompatible pointer type ‘mcontext_t *’ | expand

Commit Message

Uros Bizjak Feb. 20, 2019, 9:40 p.m. UTC
Attached patch implements the same approach that x86_64 implements to
properly cast 'mcontext_t *' &rt_->uc.uc_mcontext to 'struct
sigcontext *'.

BTW: Other targets (e.g. Mips) probably need similar patch to avoid warning.

2019-02-20  Uroš Bizjak  <ubizjak@gmail.com>

    * config/alpha/linux-unwind.h (alpha_fallback_frame_state):
    Cast 'mcontext_t *' &rt_->uc.uc_mcontext to 'struct sigcontext *'.

Tested on alphaev68-linux-gnu and committed to mainline SVN.

Uros.
diff mbox series

Patch

diff --git a/libgcc/config/alpha/linux-unwind.h b/libgcc/config/alpha/linux-unwind.h
index ec75c793454a..482564910f87 100644
--- a/libgcc/config/alpha/linux-unwind.h
+++ b/libgcc/config/alpha/linux-unwind.h
@@ -53,7 +53,10 @@  alpha_fallback_frame_state (struct _Unwind_Context *context,
 	siginfo_t info;
 	ucontext_t uc;
       } *rt_ = context->cfa;
-      sc = &rt_->uc.uc_mcontext;
+      /* The void * cast is necessary to avoid an aliasing warning.
+         The aliasing warning is correct, but should not be a problem
+         because it does not alias anything.  */
+      sc = (struct sigcontext *) (void *) &rt_->uc.uc_mcontext;
     }
   else
     return _URC_END_OF_STACK;