From: lace <> Date: Tue, 20 Dec 2005 08:39:58 +0000 (+0000) Subject: Prevent: warning: dereferencing type-punned pointer will break strict-aliasing rules X-Git-Tag: captive-1_1_6~1 X-Git-Url: http://git.jankratochvil.net/?p=reactos.git;a=commitdiff_plain;h=906444cda6c72ec439c33efd96696595b7b45f00 Prevent: warning: dereferencing type-punned pointer will break strict-aliasing rules --- diff --git a/include/ntos/types.h b/include/ntos/types.h index bbee9b8..ca61201 100644 --- a/include/ntos/types.h +++ b/include/ntos/types.h @@ -113,7 +113,10 @@ typedef wchar_t *LPWSTR; typedef wchar_t *PWSTR; typedef unsigned char *PUCHAR; typedef unsigned short *PUSHORT; -typedef void *PVOID; +/* Prevent: warning: dereferencing type-punned pointer will break strict-aliasing rules + * As PVOID is usually used for untyped generalized casts. + */ +typedef void __attribute__((__may_alias__)) *PVOID; typedef unsigned char BYTE; typedef void *LPVOID; typedef float *PFLOAT; diff --git a/ntoskrnl/ob/handle.c b/ntoskrnl/ob/handle.c index d8a6266..ebf2b7b 100644 --- a/ntoskrnl/ob/handle.c +++ b/ntoskrnl/ob/handle.c @@ -635,7 +635,12 @@ ObReferenceObjectByHandle(HANDLE Handle, if (Handle == NtCurrentProcess() && (ObjectType == PsProcessType || ObjectType == NULL)) { +/* FIXME: How to prevent?: warning: dereferencing type-punned pointer will break strict-aliasing rules + * '__attribute__((__may_alias__))' for 'PULONG' does not work. + */ +#if 0 DPRINT("Reference from %x\n", ((PULONG)&Handle)[-1]); +#endif Status = ObReferenceObjectByPointer(PsGetCurrentProcess(), PROCESS_ALL_ACCESS, @@ -710,7 +715,12 @@ ObReferenceObjectByHandle(HANDLE Handle, if (ObjectHeader->ObjectType == PsProcessType) { +/* FIXME: How to prevent?: warning: dereferencing type-punned pointer will break strict-aliasing rules + * '__attribute__((__may_alias__))' for 'PULONG' does not work. + */ +#if 0 DPRINT("Reference from %x\n", ((PULONG)&Handle)[-1]); +#endif } if (DesiredAccess && AccessMode == UserMode)