From bc72bc7f79e83f92a0d63f3761097e1203d3c76b Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Sat, 12 Apr 2014 21:44:18 +0100 Subject: [PATCH] Avoid strict aliasing warnings from gcc 4.8. Copied from Perforce Change: 185484 ServerID: perforce.ravenbrook.com --- mps/code/event.c | 2 +- mps/code/prmci3xc.c | 18 +++++++++--------- mps/code/protxc.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mps/code/event.c b/mps/code/event.c index d2166dbba2d..475fa4f875c 100644 --- a/mps/code/event.c +++ b/mps/code/event.c @@ -422,7 +422,7 @@ void EventDump(mps_lib_FILE *stream) for (kind = 0; kind < EventKindLIMIT; ++kind) { for (event = (Event)EventLast[kind]; - event < (Event)(EventBuffer[kind] + EventBufferSIZE); + (char *)event < EventBuffer[kind] + EventBufferSIZE; event = (Event)((char *)event + event->any.size)) { /* Try to keep going even if there's an error, because this is used as a backtrace and we'll take what we can get. */ diff --git a/mps/code/prmci3xc.c b/mps/code/prmci3xc.c index 786145fc084..1fcf5b149df 100644 --- a/mps/code/prmci3xc.c +++ b/mps/code/prmci3xc.c @@ -44,17 +44,17 @@ MRef Prmci3AddressHoldingReg(MutatorFaultContext mfc, unsigned int regnum) config.h. */ /* TODO: The current arrangement of the fix operation (taking a Ref *) forces us to pun these registers (actually `int` on LII3GC). We can - suppress the warning my casting through `char *` and this might make + suppress the warning by casting through `void *` and this might make it safe, but does it really? RB 2012-09-10 */ switch (regnum) { - case 0: return (MRef)((char *)&mfc->threadState->__eax); - case 1: return (MRef)((char *)&mfc->threadState->__ecx); - case 2: return (MRef)((char *)&mfc->threadState->__edx); - case 3: return (MRef)((char *)&mfc->threadState->__ebx); - case 4: return (MRef)((char *)&mfc->threadState->__esp); - case 5: return (MRef)((char *)&mfc->threadState->__ebp); - case 6: return (MRef)((char *)&mfc->threadState->__esi); - case 7: return (MRef)((char *)&mfc->threadState->__edi); + case 0: return (void *)&mfc->threadState->__eax; + case 1: return (void *)&mfc->threadState->__ecx; + case 2: return (void *)&mfc->threadState->__edx; + case 3: return (void *)&mfc->threadState->__ebx; + case 4: return (void *)&mfc->threadState->__esp; + case 5: return (void *)&mfc->threadState->__ebp; + case 6: return (void *)&mfc->threadState->__esi; + case 7: return (void *)&mfc->threadState->__edi; default: NOTREACHED; return NULL; /* Avoids compiler warning. */ diff --git a/mps/code/protxc.c b/mps/code/protxc.c index 58dee81a179..1d2ae27917c 100644 --- a/mps/code/protxc.c +++ b/mps/code/protxc.c @@ -243,7 +243,7 @@ static void protCatchOne(void) different size" warnings in GCC, for the XCI3GC build. */ mfcStruct.address = (Addr)(Word)request.code[1]; AVER(sizeof(*mfcStruct.threadState) == sizeof(THREAD_STATE_S)); - mfcStruct.threadState = (THREAD_STATE_S *)request.old_state; + mfcStruct.threadState = (void *)request.old_state; if (ArenaAccess(mfcStruct.address, AccessREAD | AccessWRITE,