From f467ab59161c0d4f3ff72bdcbc456d2a12af3878 Mon Sep 17 00:00:00 2001 From: nijtmans Date: Fri, 19 Nov 2010 20:12:23 +0000 Subject: fix gcc warning: dereferencing pointer 'oemId' does break strict-aliasing rules --- ChangeLog | 2 ++ win/tclWinInit.c | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6807c28..7664c0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * generic/tclInterp.c: fix gcc warning: passing argument 3 of 'Tcl_GetIndexFromObj' discards qualifiers from pointer target type + * generic/tclWinInit.c: fix gcc warning: dereferencing pointer + 'oemId' does break strict-aliasing rules 2010-11-18 Donal K. Fellows diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 2d923c1..59e034a 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinInit.c,v 1.75.2.1 2009/07/01 14:05:19 patthoyts Exp $ + * RCS: @(#) $Id: tclWinInit.c,v 1.75.2.2 2010/11/19 20:12:24 nijtmans Exp $ */ #include "tclWinInt.h" @@ -499,8 +499,10 @@ TclpSetVariables( { CONST char *ptr; char buffer[TCL_INTEGER_SPACE * 2]; - SYSTEM_INFO sysInfo, *sysInfoPtr = &sysInfo; - OemId *oemId; + union { + SYSTEM_INFO info; + OemId oemId; + } sys; OSVERSIONINFOA osInfo; Tcl_DString ds; WCHAR szUserName[UNLEN+1]; @@ -512,8 +514,7 @@ TclpSetVariables( osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); GetVersionExA(&osInfo); - oemId = (OemId *) sysInfoPtr; - GetSystemInfo(&sysInfo); + GetSystemInfo(&sys.info); /* * Define the tcl_platform array. @@ -527,9 +528,9 @@ TclpSetVariables( } wsprintfA(buffer, "%d.%d", osInfo.dwMajorVersion, osInfo.dwMinorVersion); Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY); - if (oemId->wProcessorArchitecture < NUMPROCESSORS) { + if (sys.oemId.wProcessorArchitecture < NUMPROCESSORS) { Tcl_SetVar2(interp, "tcl_platform", "machine", - processors[oemId->wProcessorArchitecture], + processors[sys.oemId.wProcessorArchitecture], TCL_GLOBAL_ONLY); } -- cgit v0.12