Skip to content

Commit 28397a6

Browse files
committed
Merge branch 'dscho/gcc-8-gfw-fixups'
Turns out that my fix was *not* good, as I cast a function pointer to a data pointer, and then back to a different function pointer, in an attempt to shut up GCC 8.x. But a cast between a function pointer and a data pointer is actually not allowed. It just happens to work on many CPUs, but maybe in the future we will all have CPUs that are safer and really have separate memory for code than for data (which would however break JITs). In any case, the cast's purpose was to avoid the warning by saying "yes, we know, this is a different pointer, but we know what we're doing, let's cast to `(void *)` as a generic pointer and then further to the one we know is the correct type". This works for data pointers of different types. For function pointers, the equivalent of `void *` is `void (*)(void)`. So let's use that instead. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 873ebcb + 9a1f0fe commit 28397a6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

compat/poll/poll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ win32_compute_revents (HANDLE h, int *p_sought)
149149
case FILE_TYPE_PIPE:
150150
if (!once_only)
151151
{
152-
NtQueryInformationFile = (PNtQueryInformationFile)(void *)
152+
NtQueryInformationFile = (PNtQueryInformationFile)(void (*)(void))
153153
GetProcAddress (GetModuleHandleA ("ntdll.dll"),
154154
"NtQueryInformationFile");
155155
once_only = TRUE;

compat/win32/exit-process.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ static int exit_process(HANDLE process, int exit_code)
130130
HINSTANCE kernel32 = GetModuleHandleA("kernel32");
131131
if (!kernel32)
132132
die("BUG: cannot find kernel32");
133-
exit_process_address = (LPTHREAD_START_ROUTINE)(void *)
133+
exit_process_address =
134+
(LPTHREAD_START_ROUTINE)(void (*)(void))
134135
GetProcAddress(kernel32, "ExitProcess");
135136
initialized = 1;
136137
}

0 commit comments

Comments
 (0)