unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* New warnings on emacs-26 branch with gcc 8.2.0
@ 2018-08-05 16:33 Andy Moreton
  2018-08-05 16:41 ` Noam Postavsky
  2018-08-05 19:56 ` Paul Eggert
  0 siblings, 2 replies; 60+ messages in thread
From: Andy Moreton @ 2018-08-05 16:33 UTC (permalink / raw)
  To: emacs-devel

MSYS2 has recently updated to gcc 8.2.0, and this has introduced a
number of new warnings on the emacs-26 branch.

1) 138 warnings about misuse of "-Wabi":

cc1.exe: warning: -Wabi won't warn about anything [-Wabi]
cc1.exe: note: -Wabi warns about differences from the most up-to-date ABI, which is also used by default
cc1.exe: note: use e.g. -Wabi=11 to warn about changes from GCC 7

The configury is full of a large amount of code to tune warnings, most
of which seems to be turning off things that should not have been turned
on or checked for in the first place. On Windows, bootstrapping takes an
age due to the checking of every last possible gcc warning.

Can this be simplified to be less over-zealous and less time consuming ?


2) 76 warnings from use of "-Wcast-function-type", e.g.

751:C:/emacs/git/emacs/emacs-26/lib/gettimeofday.c:48:2: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'void (*)(FILETIME *)' {aka 'void (*)(struct _FILETIME *)'} [-Wcast-function-type]

Most of these seem to be from GetProcAddress calls, where the desired
function pointer type does not match FARPROC. The gcc docs note:

    The function type void (*) (void) is special and matches
    everything, which can be used to suppress this warning.

As a workaround, this seems worse than the original problem. Can this
warning be disabled, or applied more selectively ?

There is one warning that is not related to GetProcAddress:

C:/emacs/git/emacs/emacs-26/src/emacs-module.c: In function 'Fmodule_load':
C:/emacs/git/emacs/emacs-26/src/emacs-module.c:708:17: warning: cast between incompatible function types from 'dynlib_function_ptr' {aka 'struct dynlib_function_ptr_nonce * (*)(void)'} to 'int (*)(struct emacs_runtime *)' [-Wcast-function-type]
   module_init = (emacs_init_function) dynlib_func (handle, "emacs_module_init");
                 ^
This last one appears to be showing a real problem.

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-05 16:33 New warnings on emacs-26 branch with gcc 8.2.0 Andy Moreton
@ 2018-08-05 16:41 ` Noam Postavsky
  2018-08-05 19:56 ` Paul Eggert
  1 sibling, 0 replies; 60+ messages in thread
From: Noam Postavsky @ 2018-08-05 16:41 UTC (permalink / raw)
  To: Andy Moreton; +Cc: Emacs developers

On 5 August 2018 at 12:33, Andy Moreton <andrewjmoreton@gmail.com> wrote:

> The configury is full of a large amount of code to tune warnings, most
> of which seems to be turning off things that should not have been turned
> on or checked for in the first place. On Windows, bootstrapping takes an
> age due to the checking of every last possible gcc warning.

You can reduce this by a lot with the --cache-file (or -C) configure option.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-05 16:33 New warnings on emacs-26 branch with gcc 8.2.0 Andy Moreton
  2018-08-05 16:41 ` Noam Postavsky
@ 2018-08-05 19:56 ` Paul Eggert
  2018-08-05 22:23   ` Andy Moreton
  2018-08-06  2:26   ` Eli Zaretskii
  1 sibling, 2 replies; 60+ messages in thread
From: Paul Eggert @ 2018-08-05 19:56 UTC (permalink / raw)
  To: Andy Moreton, Emacs Development

Andy Moreton wrote:

> cc1.exe: warning: -Wabi won't warn about anything [-Wabi]
> cc1.exe: note: -Wabi warns about differences from the most up-to-date ABI, which is also used by default
> cc1.exe: note: use e.g. -Wabi=11 to warn about changes from GCC 7

I noticed this problem a while ago on Fedora in several GNU projects, and fixed 
it for Emacs master in commit 2018-06-30T00:31:04!eggert@cs.ucla.edu.

To avoid the problem entirely in the emacs-26 I'd run admin/merge-gnulib and 
update everything from Gnulib as it's not worth the trouble to cherry-pick these 
sorts of fixes from master. If we'd rather not do admin/merge-gnulib, then we 
can just suggest './configure --disable-gcc-warnings' and/or 'make 
WERROR_CFLAGS=' to emacs-26 developers; either of these should work around the 
problem. (Builders from tarballs needn't worry about this, as GCC warnings are 
disabled for them by default.)

> Can this be simplified to be less over-zealous and less time consuming ?
The overzealous-warning part has been fixed on master. I'm sure 'configure' 
could be sped up, if someone wants to take the time to work on that.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-05 19:56 ` Paul Eggert
@ 2018-08-05 22:23   ` Andy Moreton
  2018-08-05 22:47     ` Paul Eggert
  2018-08-06  2:26   ` Eli Zaretskii
  1 sibling, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-05 22:23 UTC (permalink / raw)
  To: emacs-devel

On Sun 05 Aug 2018, Paul Eggert wrote:

> Andy Moreton wrote:
>
>> cc1.exe: warning: -Wabi won't warn about anything [-Wabi]
>> cc1.exe: note: -Wabi warns about differences from the most up-to-date ABI, which is also used by default
>> cc1.exe: note: use e.g. -Wabi=11 to warn about changes from GCC 7
>
> I noticed this problem a while ago on Fedora in several GNU projects, and
> fixed it for Emacs master in commit 2018-06-30T00:31:04!eggert@cs.ucla.edu.

Thanks. I don't see these -Wabi warning on master.

> To avoid the problem entirely in the emacs-26 I'd run admin/merge-gnulib and
> update everything from Gnulib as it's not worth the trouble to cherry-pick
> these sorts of fixes from master. If we'd rather not do admin/merge-gnulib,
> then we can just suggest './configure --disable-gcc-warnings' and/or 'make
> WERROR_CFLAGS=' to emacs-26 developers; either of these should work around the
> problem. (Builders from tarballs needn't worry about this, as GCC warnings are
> disabled for them by default.)

That's a decision for the maintainers, but I think it would be useful to
fix this if possible.

>> Can this be simplified to be less over-zealous and less time consuming ?
> The overzealous-warning part has been fixed on master. I'm sure 'configure'
> could be sped up, if someone wants to take the time to work on that.

Of the 562 "checking" lines when running configure on master, 146 of
them are "checking whether C compiler handles -W*". This is excessively
time consuming. Can gnulib not do less work to acheive this end, or do
the work more efficiently ?

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-05 22:23   ` Andy Moreton
@ 2018-08-05 22:47     ` Paul Eggert
  2018-08-06  8:30       ` Andy Moreton
  0 siblings, 1 reply; 60+ messages in thread
From: Paul Eggert @ 2018-08-05 22:47 UTC (permalink / raw)
  To: Andy Moreton, emacs-devel

Andy Moreton wrote:
> Of the 562 "checking" lines when running configure on master, 146 of
> them are "checking whether C compiler handles -W*". This is excessively
> time consuming. Can gnulib not do less work to acheive this end, or do
> the work more efficiently ?

Yes, it probably could, but it'd take some hacking to get it to work right. So 
far, nobody has volunteered to do that. It'd be nontrivial, as the 
configure-time code needs to work with older GCCs and with compilers other than GCC.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-05 19:56 ` Paul Eggert
  2018-08-05 22:23   ` Andy Moreton
@ 2018-08-06  2:26   ` Eli Zaretskii
  2018-08-06  3:16     ` Paul Eggert
  1 sibling, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-06  2:26 UTC (permalink / raw)
  To: Paul Eggert; +Cc: andrewjmoreton, Emacs-devel

> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Sun, 5 Aug 2018 12:56:45 -0700
> 
> > cc1.exe: warning: -Wabi won't warn about anything [-Wabi]
> > cc1.exe: note: -Wabi warns about differences from the most up-to-date ABI, which is also used by default
> > cc1.exe: note: use e.g. -Wabi=11 to warn about changes from GCC 7
> 
> I noticed this problem a while ago on Fedora in several GNU projects, and fixed 
> it for Emacs master in commit 2018-06-30T00:31:04!eggert@cs.ucla.edu.
> 
> To avoid the problem entirely in the emacs-26 I'd run admin/merge-gnulib and 
> update everything from Gnulib as it's not worth the trouble to cherry-pick these 
> sorts of fixes from master. If we'd rather not do admin/merge-gnulib, then we 
> can just suggest './configure --disable-gcc-warnings' and/or 'make 
> WERROR_CFLAGS=' to emacs-26 developers; either of these should work around the 
> problem. (Builders from tarballs needn't worry about this, as GCC warnings are 
> disabled for them by default.)

Since this warning is disabled when building the tarball, I'd like to
avoid excessive changes on its behalf.  Would it make sense instead to
disable -Wabi on emacs-26?  If not, I'd leave these warnings alone.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-06  2:26   ` Eli Zaretskii
@ 2018-08-06  3:16     ` Paul Eggert
  2018-08-11  8:40       ` Eli Zaretskii
  0 siblings, 1 reply; 60+ messages in thread
From: Paul Eggert @ 2018-08-06  3:16 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: andrewjmoreton, Emacs-devel

Eli Zaretskii wrote:
> Would it make sense instead to
> disable -Wabi on emacs-26?

I suppose so; I don't know that much about -Wabi.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-05 22:47     ` Paul Eggert
@ 2018-08-06  8:30       ` Andy Moreton
  2018-08-06 15:16         ` Eli Zaretskii
  2018-08-06 18:37         ` Paul Eggert
  0 siblings, 2 replies; 60+ messages in thread
From: Andy Moreton @ 2018-08-06  8:30 UTC (permalink / raw)
  To: emacs-devel

On Sun 05 Aug 2018, Paul Eggert wrote:

> Andy Moreton wrote:
>> Of the 562 "checking" lines when running configure on master, 146 of
>> them are "checking whether C compiler handles -W*". This is excessively
>> time consuming. Can gnulib not do less work to acheive this end, or do
>> the work more efficiently ?
>
> Yes, it probably could, but it'd take some hacking to get it to work right. So
> far, nobody has volunteered to do that. It'd be nontrivial, as the
> configure-time code needs to work with older GCCs and with compilers other
> than GCC.

Why does it need to check every gcc warning though, rather than just the
-W* and -Wno-* warnings that have been requested in the configury ?

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-06  8:30       ` Andy Moreton
@ 2018-08-06 15:16         ` Eli Zaretskii
  2018-08-06 15:26           ` Andy Moreton
  2018-08-06 18:37         ` Paul Eggert
  1 sibling, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-06 15:16 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Mon, 06 Aug 2018 09:30:27 +0100
> 
> Why does it need to check every gcc warning though, rather than just the
> -W* and -Wno-* warnings that have been requested in the configury ?

Because different versions of GCC support different warning options,
and using an option that is not supported by the installed version of
GCC will cause warnings and sometimes errors.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-06 15:16         ` Eli Zaretskii
@ 2018-08-06 15:26           ` Andy Moreton
  2018-08-06 15:34             ` Eli Zaretskii
  0 siblings, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-06 15:26 UTC (permalink / raw)
  To: emacs-devel

On Mon 06 Aug 2018, Eli Zaretskii wrote:

>> From: Andy Moreton <andrewjmoreton@gmail.com>
>> Date: Mon, 06 Aug 2018 09:30:27 +0100
>> 
>> Why does it need to check every gcc warning though, rather than just the
>> -W* and -Wno-* warnings that have been requested in the configury ?
>
> Because different versions of GCC support different warning options,
> and using an option that is not supported by the installed version of
> GCC will cause warnings and sometimes errors.

That is not what is being discussed. The configure script run 146 checks
to determine if gcc warning options are supported, but the emacs
configure script mentions a far smaller number.

Why are dozens of configure checks being run for things that emacs
configure does not care about, and whose only effect is to slow down
the build ?

    AndyM





^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-06 15:26           ` Andy Moreton
@ 2018-08-06 15:34             ` Eli Zaretskii
  0 siblings, 0 replies; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-06 15:34 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Mon, 06 Aug 2018 16:26:17 +0100
> 
> >> Why does it need to check every gcc warning though, rather than just the
> >> -W* and -Wno-* warnings that have been requested in the configury ?
> >
> > Because different versions of GCC support different warning options,
> > and using an option that is not supported by the installed version of
> > GCC will cause warnings and sometimes errors.
> 
> That is not what is being discussed. The configure script run 146 checks
> to determine if gcc warning options are supported, but the emacs
> configure script mentions a far smaller number.

Sorry for my misunderstanding.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-06  8:30       ` Andy Moreton
  2018-08-06 15:16         ` Eli Zaretskii
@ 2018-08-06 18:37         ` Paul Eggert
  2018-08-06 21:36           ` Andy Moreton
  1 sibling, 1 reply; 60+ messages in thread
From: Paul Eggert @ 2018-08-06 18:37 UTC (permalink / raw)
  To: Andy Moreton, emacs-devel

Andy Moreton wrote:
> Why does it need to check every gcc warning though, rather than just the
> -W* and -Wno-* warnings that have been requested in the configury ?

Sorry, I don't remember. However, if you'd like to dig through this and suggest 
specific improvements, I'm sure we'll be all ears. Nobody likes how long this 
stuff takes.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-06 18:37         ` Paul Eggert
@ 2018-08-06 21:36           ` Andy Moreton
  2018-08-06 21:58             ` Paul Eggert
  0 siblings, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-06 21:36 UTC (permalink / raw)
  To: emacs-devel

On Mon 06 Aug 2018, Paul Eggert wrote:

> Andy Moreton wrote:
>> Why does it need to check every gcc warning though, rather than just the
>> -W* and -Wno-* warnings that have been requested in the configury ?
>
> Sorry, I don't remember. However, if you'd like to dig through this and
> suggest specific improvements, I'm sure we'll be all ears. Nobody likes how
> long this stuff takes.

I was hoping you could provide more background, as you are are shown as
the most recent committer of almost every line of configure.ac related
to warnings.

Is this problem arising from use of the gnulib manywarnings module ? If
so, why do we use it and not the simpler gnuslib warnings module ?

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-06 21:36           ` Andy Moreton
@ 2018-08-06 21:58             ` Paul Eggert
  2018-08-11 15:06               ` Andy Moreton
  0 siblings, 1 reply; 60+ messages in thread
From: Paul Eggert @ 2018-08-06 21:58 UTC (permalink / raw)
  To: Andy Moreton, emacs-devel

Andy Moreton wrote:
> I was hoping you could provide more background, as you are are shown as
> the most recent committer of almost every line of configure.ac related
> to warnings.

Yes, I adapt this stuff for Emacs. However, it sounds like the part you want 
changed comes from a part of Gnulib that I do not know as well.

> Is this problem arising from use of the gnulib manywarnings module ? If
> so, why do we use it and not the simpler gnuslib warnings module ?

The warnings module would require the hand-maintained Emacs source code to list 
the exact set of warnings that it wants, which would be a pain to maintain as 
the set commonly changes after each GCC release. The manywarnings module 
maintains such a list for us, which is simpler for Emacs proper (and allows us 
to share this mutating list among several GNU projects). The Emacs configure.ac 
tailors the Gnulib list a bit, but mostly leaves it alone; this is simpler for 
Emacs than maintaining its own sort-of-copy of the list by hand.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-06  3:16     ` Paul Eggert
@ 2018-08-11  8:40       ` Eli Zaretskii
  2018-08-11 10:41         ` Andy Moreton
  0 siblings, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-11  8:40 UTC (permalink / raw)
  To: Paul Eggert; +Cc: andrewjmoreton, Emacs-devel

> Cc: andrewjmoreton@gmail.com, Emacs-devel@gnu.org
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Sun, 5 Aug 2018 20:16:50 -0700
> 
> Eli Zaretskii wrote:
> > Would it make sense instead to
> > disable -Wabi on emacs-26?
> 
> I suppose so; I don't know that much about -Wabi.

OK, I've now done so.  Andrew, please see if this fixes the original
problem with this warning.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11  8:40       ` Eli Zaretskii
@ 2018-08-11 10:41         ` Andy Moreton
  2018-08-11 10:51           ` Eli Zaretskii
  0 siblings, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-11 10:41 UTC (permalink / raw)
  To: emacs-devel

On Sat 11 Aug 2018, Eli Zaretskii wrote:

>> Cc: andrewjmoreton@gmail.com, Emacs-devel@gnu.org
>> From: Paul Eggert <eggert@cs.ucla.edu>
>> Date: Sun, 5 Aug 2018 20:16:50 -0700
>> 
>> Eli Zaretskii wrote:
>> > Would it make sense instead to
>> > disable -Wabi on emacs-26?
>> 
>> I suppose so; I don't know that much about -Wabi.
>
> OK, I've now done so.  Andrew, please see if this fixes the original
> problem with this warning.

Yes, that ha removed that batch of warnings.

There are still other warnings: one from -Wformat-overflow and 78 from
-Wcast-function-type.

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 10:41         ` Andy Moreton
@ 2018-08-11 10:51           ` Eli Zaretskii
  2018-08-11 15:02             ` Andy Moreton
  0 siblings, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-11 10:51 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Sat, 11 Aug 2018 11:41:20 +0100
> 
> > OK, I've now done so.  Andrew, please see if this fixes the original
> > problem with this warning.
> 
> Yes, that ha removed that batch of warnings.

Thanks for testing.

> There are still other warnings: one from -Wformat-overflow and 78 from
> -Wcast-function-type.

Can you show the warnings from -Wcast-function-type?



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 10:51           ` Eli Zaretskii
@ 2018-08-11 15:02             ` Andy Moreton
  2018-08-11 17:15               ` Eli Zaretskii
  0 siblings, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-11 15:02 UTC (permalink / raw)
  To: emacs-devel

On Sat 11 Aug 2018, Eli Zaretskii wrote:

>> From: Andy Moreton <andrewjmoreton@gmail.com>
>> Date: Sat, 11 Aug 2018 11:41:20 +0100
>> 
>> > OK, I've now done so.  Andrew, please see if this fixes the original
>> > problem with this warning.
>> 
>> Yes, that ha removed that batch of warnings.
>
> Thanks for testing.
>
>> There are still other warnings: one from -Wformat-overflow and 78 from
>> -Wcast-function-type.
>
> Can you show the warnings from -Wcast-function-type?

Here are the warnings from commit ec6f588940e5, built with gcc 8.2.0.
Mostly this seems to be GetProcAddress results, where it complains that
FARPROC and the desired fuinction type don't match. The gcc manual says
that casting via "void (*)(void)" can be used to pacify the warning.


  CC       dynlib.o
C:/emacs/git/emacs/emacs-26/src/dynlib.c: In function 'dynlib_addr':
C:/emacs/git/emacs/emacs-26/src/dynlib.c:160:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(DWORD,  const CHAR *, struct HINSTANCE__ **)' {aka 'int (*)(long unsigned int,  const char *, struct HINSTANCE__ **)'} [-Wcast-function-type]
      (GetModuleHandleExA_Proc) GetProcAddress (hm_kernel32,
      ^
  CC       emacs-module.o
C:/emacs/git/emacs/emacs-26/src/emacs-module.c: In function 'Fmodule_load':
C:/emacs/git/emacs/emacs-26/src/emacs-module.c:708:17: warning: cast between incompatible function types from 'dynlib_function_ptr' {aka 'struct dynlib_function_ptr_nonce * (*)(void)'} to 'int (*)(struct emacs_runtime *)' [-Wcast-function-type]
   module_init = (emacs_init_function) dynlib_func (handle, "emacs_module_init");
                 ^
  CC       w32fns.o
C:/emacs/git/emacs/emacs-26/src/w32fns.c: In function 'setup_w32_kbdhook':
C:/emacs/git/emacs/emacs-26/src/w32fns.c:2642:52: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void)' {aka 'int (*)(void)'} [-Wcast-function-type]
       IsDebuggerPresent_Proc is_debugger_present = (IsDebuggerPresent_Proc)
                                                    ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:2657:43: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'struct HWND__ * (*)(void)' [-Wcast-function-type]
       GetConsoleWindow_Proc get_console = (GetConsoleWindow_Proc)
                                           ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c: In function 'Ffile_system_info':
C:/emacs/git/emacs/emacs-26/src/w32fns.c:9376:7: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(const WCHAR *, ULARGE_INTEGER *, ULARGE_INTEGER *, ULARGE_INTEGER *)' {aka 'int (*)(const short unsigned int *, union _ULARGE_INTEGER *, union _ULARGE_INTEGER *, union _ULARGE_INTEGER *)'} [-Wcast-function-type]
       (GetDiskFreeSpaceExW_Proc) GetProcAddress (hKernel, "GetDiskFreeSpaceExW");
       ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:9378:7: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(const CHAR *, ULARGE_INTEGER *, ULARGE_INTEGER *, ULARGE_INTEGER *)' {aka 'int (*)(const char *, union _ULARGE_INTEGER *, union _ULARGE_INTEGER *, union _ULARGE_INTEGER *)'} [-Wcast-function-type]
       (GetDiskFreeSpaceExA_Proc) GetProcAddress (hKernel, "GetDiskFreeSpaceExA");
       ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c: In function 'get_dll_version':
C:/emacs/git/emacs/emacs-26/src/w32fns.c:9954:4: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(DLLVERSIONINFO *)' {aka 'long int (*)(struct _DLLVERSIONINFO *)'} [-Wcast-function-type]
  = (DLLGETVERSIONPROC) GetProcAddress (hdll, "DllGetVersion");
    ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c: In function 'w32_reset_stack_overflow_guard':
C:/emacs/git/emacs/emacs-26/src/w32fns.c:10856:7: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'int (*)(void)' [-Wcast-function-type]
       (_resetstkoflw_proc)GetProcAddress (GetModuleHandle ("msvcrt.dll"),
       ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c: In function 'w32_backtrace':
C:/emacs/git/emacs/emacs-26/src/w32fns.c:10932:2: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'USHORT (*)(ULONG,  ULONG,  void **, ULONG *)' {aka 'short unsigned int (*)(long unsigned int,  long unsigned int,  void **, long unsigned int *)'} [-Wcast-function-type]
  (CaptureStackBackTrace_proc) GetProcAddress (hm_kernel32,
  ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c: In function 'globals_of_w32fns':
C:/emacs/git/emacs/emacs-26/src/w32fns.c:11065:26: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct tagTRACKMOUSEEVENT *)' {aka 'int (*)(struct tagTRACKMOUSEEVENT *)'} [-Wcast-function-type]
   track_mouse_event_fn = (TrackMouseEvent_Proc)
                          ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:11068:27: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'struct HMONITOR__ * (*)(POINT,  DWORD)' {aka 'struct HMONITOR__ * (*)(struct tagPOINT,  long unsigned int)'} [-Wcast-function-type]
   monitor_from_point_fn = (MonitorFromPoint_Proc)
                           ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:11070:25: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct HMONITOR__ *, struct MONITOR_INFO *)' {aka 'int (*)(struct HMONITOR__ *, struct MONITOR_INFO *)'} [-Wcast-function-type]
   get_monitor_info_fn = (GetMonitorInfo_Proc)
                         ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:11072:28: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'struct HMONITOR__ * (*)(struct HWND__ *, DWORD)' {aka 'struct HMONITOR__ * (*)(struct HWND__ *, long unsigned int)'} [-Wcast-function-type]
   monitor_from_window_fn = (MonitorFromWindow_Proc)
                            ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:11074:30: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct HDC__ *, RECT *, BOOL (*)(struct HMONITOR__ *, struct HDC__ *, RECT *, LPARAM), LPARAM)' {aka 'int (*)(struct HDC__ *, struct tagRECT *, int (*)(struct HMONITOR__ *, struct HDC__ *, struct tagRECT *, long long int), long long int)'} [-Wcast-function-type]
   enum_display_monitors_fn = (EnumDisplayMonitors_Proc)
                              ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:11076:27: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct HWND__ *, TITLEBAR_INFO *)' {aka 'int (*)(struct HWND__ *, struct <anonymous> *)'} [-Wcast-function-type]
   get_title_bar_info_fn = (GetTitleBarInfo_Proc)
                           ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:11081:33: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'LONG (*)(struct HIMC__ *, DWORD,  void *, DWORD)' {aka 'long int (*)(struct HIMC__ *, long unsigned int,  void *, long unsigned int)'} [-Wcast-function-type]
     get_composition_string_fn = (ImmGetCompositionString_Proc)
                                 ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:11083:26: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'struct HIMC__ * (*)(struct HWND__ *)' [-Wcast-function-type]
     get_ime_context_fn = (ImmGetContext_Proc)
                          ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:11085:30: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct HWND__ *, struct HIMC__ *)' {aka 'int (*)(struct HWND__ *, struct HIMC__ *)'} [-Wcast-function-type]
     release_ime_context_fn = (ImmReleaseContext_Proc)
                              ^
C:/emacs/git/emacs/emacs-26/src/w32fns.c:11087:37: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct HIMC__ *, COMPOSITIONFORM *)' {aka 'int (*)(struct HIMC__ *, struct tagCOMPOSITIONFORM *)'} [-Wcast-function-type]
     set_ime_composition_window_fn = (ImmSetCompositionWindow_Proc)
                                     ^
  CC       w32menu.o
C:/emacs/git/emacs/emacs-26/src/w32menu.c: In function 'globals_of_w32menu':
C:/emacs/git/emacs/emacs-26/src/w32menu.c:1609:24: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct HMENU__ *, UINT,  BOOL,  struct tagMENUITEMINFOA *)' {aka 'int (*)(struct HMENU__ *, unsigned int,  int,  struct tagMENUITEMINFOA *)'} [-Wcast-function-type]
   get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
                        ^
C:/emacs/git/emacs/emacs-26/src/w32menu.c:1610:24: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct HMENU__ *, UINT,  BOOL,  const MENUITEMINFOA *)' {aka 'int (*)(struct HMENU__ *, unsigned int,  int,  const struct tagMENUITEMINFOA *)'} [-Wcast-function-type]
   set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
                        ^
C:/emacs/git/emacs/emacs-26/src/w32menu.c:1611:25: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct HMENU__ *, UINT,  UINT_PTR,  const WCHAR *)' {aka 'int (*)(struct HMENU__ *, unsigned int,  long long unsigned int,  const short unsigned int *)'} [-Wcast-function-type]
   unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
                         ^
C:/emacs/git/emacs/emacs-26/src/w32menu.c:1612:25: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'int (*)(struct HWND__ *, const WCHAR *, const WCHAR *, UINT)' {aka 'int (*)(struct HWND__ *, const short unsigned int *, const short unsigned int *, unsigned int)'} [-Wcast-function-type]
   unicode_message_box = (MessageBoxW_Proc) GetProcAddress (user32, "MessageBoxW");
                         ^
  CC       w32font.o
C:/emacs/git/emacs/emacs-26/src/w32font.c: In function 'get_outline_metrics_w':
C:/emacs/git/emacs/emacs-26/src/w32font.c:155:36: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'UINT (*)(struct HDC__ *, UINT,  struct _OUTLINETEXTMETRICW *)' {aka 'unsigned int (*)(struct HDC__ *, unsigned int,  struct _OUTLINETEXTMETRICW *)'} [-Wcast-function-type]
  s_pfn_Get_Outline_Text_MetricsW = (GetOutlineTextMetricsW_Proc)
                                    ^
C:/emacs/git/emacs/emacs-26/src/w32font.c: In function 'get_text_metrics_w':
C:/emacs/git/emacs/emacs-26/src/w32font.c:172:28: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct HDC__ *, struct tagTEXTMETRICW *)' {aka 'int (*)(struct HDC__ *, struct tagTEXTMETRICW *)'} [-Wcast-function-type]
  s_pfn_Get_Text_MetricsW = (GetTextMetricsW_Proc)
                            ^
C:/emacs/git/emacs/emacs-26/src/w32font.c: In function 'get_glyph_outline_w':
C:/emacs/git/emacs/emacs-26/src/w32font.c:190:29: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'DWORD (*)(struct HDC__ *, UINT,  UINT,  struct _GLYPHMETRICS *, DWORD,  void *, const MAT2 *)' {aka 'long unsigned int (*)(struct HDC__ *, unsigned int,  unsigned int,  struct _GLYPHMETRICS *, long unsigned int,  void *, const struct _MAT2 *)'} [-Wcast-function-type]
  s_pfn_Get_Glyph_OutlineW = (GetGlyphOutlineW_Proc)
                             ^
C:/emacs/git/emacs/emacs-26/src/w32font.c: In function 'get_char_width_32_w':
C:/emacs/git/emacs/emacs-26/src/w32font.c:208:29: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct HDC__ *, UINT,  UINT,  int *)' {aka 'int (*)(struct HDC__ *, unsigned int,  unsigned int,  int *)'} [-Wcast-function-type]
  s_pfn_Get_Char_Width_32W = (GetCharWidth32W_Proc)
                             ^
  CC       w32uniscribe.o
C:/emacs/git/emacs/emacs-26/src/w32uniscribe.c: In function 'syms_of_w32uniscribe':
C:/emacs/git/emacs/emacs-26/src/w32uniscribe.c:1196:32: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(struct HDC__ *, void **, SCRIPT_ANALYSIS *, int,  OPENTYPE_TAG *, int *)' {aka 'long int (*)(struct HDC__ *, void **, struct tag_SCRIPT_ANALYSIS *, int,  long unsigned int *, int *)'} [-Wcast-function-type]
   script_get_font_scripts_fn = (ScriptGetFontScriptTags_Proc)
                                ^
C:/emacs/git/emacs/emacs-26/src/w32uniscribe.c:1198:34: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(struct HDC__ *, void **, SCRIPT_ANALYSIS *, OPENTYPE_TAG,  int,  OPENTYPE_TAG *, int *)' {aka 'long int (*)(struct HDC__ *, void **, struct tag_SCRIPT_ANALYSIS *, long unsigned int,  int,  long unsigned int *, int *)'} [-Wcast-function-type]
   script_get_font_languages_fn = (ScriptGetFontLanguageTags_Proc)
                                  ^
C:/emacs/git/emacs/emacs-26/src/w32uniscribe.c:1200:33: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(struct HDC__ *, void **, SCRIPT_ANALYSIS *, OPENTYPE_TAG,  OPENTYPE_TAG,  int,  OPENTYPE_TAG *, int *)' {aka 'long int (*)(struct HDC__ *, void **, struct tag_SCRIPT_ANALYSIS *, long unsigned int,  long unsigned int,  int,  long unsigned int *, int *)'} [-Wcast-function-type]
   script_get_font_features_fn = (ScriptGetFontFeatureTags_Proc)
                                 ^
  CC       w32.o
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'open_process_token':
C:/emacs/git/emacs/emacs-26/src/w32.c:574:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, DWORD,  void **)' {aka 'int (*)(void *, long unsigned int,  void **)'} [-Wcast-function-type]
         (OpenProcessToken_Proc) GetProcAddress (hm_advapi32, "OpenProcessToken");
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_token_information':
C:/emacs/git/emacs/emacs-26/src/w32.c:606:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, TOKEN_INFORMATION_CLASS,  void *, DWORD,  DWORD *)' {aka 'int (*)(void *, enum _TOKEN_INFORMATION_CLASS,  void *, long unsigned int,  long unsigned int *)'} [-Wcast-function-type]
         (GetTokenInformation_Proc) GetProcAddress (hm_advapi32, "GetTokenInformation");
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'lookup_account_sid':
C:/emacs/git/emacs/emacs-26/src/w32.c:642:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(const CHAR *, void *, CHAR *, DWORD *, CHAR *, DWORD *, enum _SID_NAME_USE *)' {aka 'int (*)(const char *, void *, char *, long unsigned int *, char *, long unsigned int *, enum _SID_NAME_USE *)'} [-Wcast-function-type]
         (LookupAccountSid_Proc) GetProcAddress (hm_advapi32, LookupAccountSid_Name);
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_sid_sub_authority':
C:/emacs/git/emacs/emacs-26/src/w32.c:675:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'DWORD * (*)(void *, DWORD)' {aka 'long unsigned int * (*)(void *, long unsigned int)'} [-Wcast-function-type]
         (GetSidSubAuthority_Proc) GetProcAddress (
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_sid_sub_authority_count':
C:/emacs/git/emacs/emacs-26/src/w32.c:700:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'UCHAR * (*)(void *)' {aka 'unsigned char * (*)(void *)'} [-Wcast-function-type]
         (GetSidSubAuthorityCount_Proc) GetProcAddress (
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_security_info':
C:/emacs/git/emacs/emacs-26/src/w32.c:731:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'DWORD (*)(void *, SE_OBJECT_TYPE,  SECURITY_INFORMATION,  void **, void **, ACL **, ACL **, void **)' {aka 'long unsigned int (*)(void *, enum _SE_OBJECT_TYPE,  long unsigned int,  void **, void **, struct _ACL **, struct _ACL **, void **)'} [-Wcast-function-type]
         (GetSecurityInfo_Proc) GetProcAddress (
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_file_security':
C:/emacs/git/emacs/emacs-26/src/w32.c:767:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(const WCHAR *, SECURITY_INFORMATION,  void *, DWORD,  DWORD *)' {aka 'int (*)(const short unsigned int *, long unsigned int,  void *, long unsigned int,  long unsigned int *)'} [-Wcast-function-type]
      (GetFileSecurityW_Proc) GetProcAddress (hm_advapi32,
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c:789:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(const CHAR *, SECURITY_INFORMATION,  void *, DWORD,  DWORD *)' {aka 'int (*)(const char *, long unsigned int,  void *, long unsigned int,  long unsigned int *)'} [-Wcast-function-type]
      (GetFileSecurityA_Proc) GetProcAddress (hm_advapi32,
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'set_file_security':
C:/emacs/git/emacs/emacs-26/src/w32.c:826:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(const WCHAR *, SECURITY_INFORMATION,  void *)' {aka 'int (*)(const short unsigned int *, long unsigned int,  void *)'} [-Wcast-function-type]
      (SetFileSecurityW_Proc) GetProcAddress (hm_advapi32,
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c:847:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(const CHAR *, SECURITY_INFORMATION,  void *)' {aka 'int (*)(const char *, long unsigned int,  void *)'} [-Wcast-function-type]
      (SetFileSecurityA_Proc) GetProcAddress (hm_advapi32,
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'set_named_security_info':
C:/emacs/git/emacs/emacs-26/src/w32.c:887:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'DWORD (*)(const WCHAR *, SE_OBJECT_TYPE,  SECURITY_INFORMATION,  void *, void *, ACL *, ACL *)' {aka 'long unsigned int (*)(const short unsigned int *, enum _SE_OBJECT_TYPE,  long unsigned int,  void *, void *, struct _ACL *, struct _ACL *)'} [-Wcast-function-type]
      (SetNamedSecurityInfoW_Proc) GetProcAddress (hm_advapi32,
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c:909:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'DWORD (*)(const CHAR *, SE_OBJECT_TYPE,  SECURITY_INFORMATION,  void *, void *, ACL *, ACL *)' {aka 'long unsigned int (*)(const char *, enum _SE_OBJECT_TYPE,  long unsigned int,  void *, void *, struct _ACL *, struct _ACL *)'} [-Wcast-function-type]
      (SetNamedSecurityInfoA_Proc) GetProcAddress (hm_advapi32,
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_security_descriptor_owner':
C:/emacs/git/emacs/emacs-26/src/w32.c:941:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, void **, WINBOOL *)' {aka 'int (*)(void *, void **, int *)'} [-Wcast-function-type]
         (GetSecurityDescriptorOwner_Proc) GetProcAddress (
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_security_descriptor_group':
C:/emacs/git/emacs/emacs-26/src/w32.c:970:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, void **, WINBOOL *)' {aka 'int (*)(void *, void **, int *)'} [-Wcast-function-type]
         (GetSecurityDescriptorGroup_Proc) GetProcAddress (
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_security_descriptor_dacl':
C:/emacs/git/emacs/emacs-26/src/w32.c:1000:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, WINBOOL *, ACL **, WINBOOL *)' {aka 'int (*)(void *, int *, struct _ACL **, int *)'} [-Wcast-function-type]
         (GetSecurityDescriptorDacl_Proc) GetProcAddress (
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'is_valid_sid':
C:/emacs/git/emacs/emacs-26/src/w32.c:1027:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *)' {aka 'int (*)(void *)'} [-Wcast-function-type]
         (IsValidSid_Proc) GetProcAddress (
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'equal_sid':
C:/emacs/git/emacs/emacs-26/src/w32.c:1051:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, void *)' {aka 'int (*)(void *, void *)'} [-Wcast-function-type]
         (EqualSid_Proc) GetProcAddress (
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_length_sid':
C:/emacs/git/emacs/emacs-26/src/w32.c:1075:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'DWORD (*)(void *)' {aka 'long unsigned int (*)(void *)'} [-Wcast-function-type]
         (GetLengthSid_Proc) GetProcAddress (
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'copy_sid':
C:/emacs/git/emacs/emacs-26/src/w32.c:1099:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(DWORD,  void *, void *)' {aka 'int (*)(long unsigned int,  void *, void *)'} [-Wcast-function-type]
         (CopySid_Proc) GetProcAddress (
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_native_system_info':
C:/emacs/git/emacs/emacs-26/src/w32.c:1125:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'void (*)(struct _SYSTEM_INFO *)' [-Wcast-function-type]
      (GetNativeSystemInfo_Proc)GetProcAddress (GetModuleHandle ("kernel32.dll"),
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_system_times':
C:/emacs/git/emacs/emacs-26/src/w32.c:1149:2: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct _FILETIME *, struct _FILETIME *, struct _FILETIME *)' {aka 'int (*)(struct _FILETIME *, struct _FILETIME *, struct _FILETIME *)'} [-Wcast-function-type]
  (GetSystemTimes_Proc)GetProcAddress (GetModuleHandle ("kernel32.dll"),
  ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'create_symbolic_link':
C:/emacs/git/emacs/emacs-26/src/w32.c:1179:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOLEAN (*)(const WCHAR *, const WCHAR *, DWORD)' {aka 'unsigned char (*)(const short unsigned int *, const short unsigned int *, long unsigned int)'} [-Wcast-function-type]
      (CreateSymbolicLinkW_Proc)GetProcAddress (GetModuleHandle ("kernel32.dll"),
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c:1214:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOLEAN (*)(const CHAR *, const CHAR *, DWORD)' {aka 'unsigned char (*)(const char *, const char *, long unsigned int)'} [-Wcast-function-type]
      (CreateSymbolicLinkA_Proc)GetProcAddress (GetModuleHandle ("kernel32.dll"),
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'is_valid_security_descriptor':
C:/emacs/git/emacs/emacs-26/src/w32.c:1259:2: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *)' {aka 'int (*)(void *)'} [-Wcast-function-type]
  (IsValidSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
  ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'convert_sd_to_sddl':
C:/emacs/git/emacs/emacs-26/src/w32.c:1296:2: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, DWORD,  SECURITY_INFORMATION,  CHAR **, ULONG *)' {aka 'int (*)(void *, long unsigned int,  long unsigned int,  char **, long unsigned int *)'} [-Wcast-function-type]
  (ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
  ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'convert_sddl_to_sd':
C:/emacs/git/emacs/emacs-26/src/w32.c:1339:2: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(const CHAR *, DWORD,  void **, ULONG *)' {aka 'int (*)(const char *, long unsigned int,  void **, long unsigned int *)'} [-Wcast-function-type]
  (ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
  ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_adapters_info':
C:/emacs/git/emacs/emacs-26/src/w32.c:1371:28: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'DWORD (*)(struct _IP_ADAPTER_INFO *, ULONG *)' {aka 'long unsigned int (*)(struct _IP_ADAPTER_INFO *, long unsigned int *)'} [-Wcast-function-type]
  s_pfn_Get_Adapters_Info = (GetAdaptersInfo_Proc)
                            ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'init_environment':
C:/emacs/git/emacs/emacs-26/src/w32.c:2730:20: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(struct HWND__ *, int,  void *, DWORD,  char *)' {aka 'long int (*)(struct HWND__ *, int,  void *, long unsigned int,  char *)'} [-Wcast-function-type]
  get_folder_path = (ShGetFolderPath_fn)
                    ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'create_toolhelp32_snapshot':
C:/emacs/git/emacs/emacs-26/src/w32.c:6562:42: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'void * (*)(DWORD,  DWORD)' {aka 'void * (*)(long unsigned int,  long unsigned int)'} [-Wcast-function-type]
       s_pfn_Create_Toolhelp32_Snapshot = (CreateToolhelp32Snapshot_Proc)
                                          ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'process32_first':
C:/emacs/git/emacs/emacs-26/src/w32.c:6581:31: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, PROCESSENTRY32 *)' {aka 'int (*)(void *, struct tagPROCESSENTRY32 *)'} [-Wcast-function-type]
       s_pfn_Process32_First = (Process32First_Proc)
                               ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'process32_next':
C:/emacs/git/emacs/emacs-26/src/w32.c:6600:30: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, PROCESSENTRY32 *)' {aka 'int (*)(void *, struct tagPROCESSENTRY32 *)'} [-Wcast-function-type]
       s_pfn_Process32_Next = (Process32Next_Proc)
                              ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'open_thread_token':
C:/emacs/git/emacs/emacs-26/src/w32.c:6629:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, DWORD,  BOOL,  void **)' {aka 'int (*)(void *, long unsigned int,  int,  void **)'} [-Wcast-function-type]
         (OpenThreadToken_Proc) GetProcAddress (hm_advapi32, "OpenThreadToken");
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'impersonate_self':
C:/emacs/git/emacs/emacs-26/src/w32.c:6659:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(SECURITY_IMPERSONATION_LEVEL)' {aka 'int (*)(enum _SECURITY_IMPERSONATION_LEVEL)'} [-Wcast-function-type]
         (ImpersonateSelf_Proc) GetProcAddress (hm_advapi32, "ImpersonateSelf");
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'revert_to_self':
C:/emacs/git/emacs/emacs-26/src/w32.c:6682:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void)' {aka 'int (*)(void)'} [-Wcast-function-type]
         (RevertToSelf_Proc) GetProcAddress (hm_advapi32, "RevertToSelf");
         ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_process_memory_info':
C:/emacs/git/emacs/emacs-26/src/w32.c:6707:34: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, PROCESS_MEMORY_COUNTERS *, DWORD)' {aka 'int (*)(void *, struct _PROCESS_MEMORY_COUNTERS *, long unsigned int)'} [-Wcast-function-type]
  s_pfn_Get_Process_Memory_Info = (GetProcessMemoryInfo_Proc)
                                  ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'get_process_working_set_size':
C:/emacs/git/emacs/emacs-26/src/w32.c:6732:44: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, ULONG_PTR *, ULONG_PTR *)' {aka 'int (*)(void *, long long unsigned int *, long long unsigned int *)'} [-Wcast-function-type]
       s_pfn_Get_Process_Working_Set_Size = (GetProcessWorkingSetSize_Proc)
                                            ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'global_memory_status':
C:/emacs/git/emacs/emacs-26/src/w32.c:6755:36: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct _MEMORYSTATUS *)' {aka 'int (*)(struct _MEMORYSTATUS *)'} [-Wcast-function-type]
       s_pfn_Global_Memory_Status = (GlobalMemoryStatus_Proc)
                                    ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'global_memory_status_ex':
C:/emacs/git/emacs/emacs-26/src/w32.c:6778:39: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(struct _MEMORY_STATUS_EX *)' {aka 'int (*)(struct _MEMORY_STATUS_EX *)'} [-Wcast-function-type]
       s_pfn_Global_Memory_Status_Ex = (GlobalMemoryStatusEx_Proc)
                                       ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'maybe_load_unicows_dll':
C:/emacs/git/emacs/emacs-26/src/w32.c:9607:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'int (*)(UINT,  DWORD,  const CHAR *, int,  WCHAR *, int)' {aka 'int (*)(unsigned int,  long unsigned int,  const char *, int,  short unsigned int *, int)'} [-Wcast-function-type]
      (MultiByteToWideChar_Proc)GetProcAddress (ret, "MultiByteToWideChar");
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c:9609:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'int (*)(UINT,  DWORD,  const WCHAR *, int,  CHAR *, int,  const CHAR *, WINBOOL *)' {aka 'int (*)(unsigned int,  long unsigned int,  const short unsigned int *, int,  char *, int,  const char *, int *)'} [-Wcast-function-type]
      (WideCharToMultiByte_Proc)GetProcAddress (ret, "WideCharToMultiByte");
      ^
C:/emacs/git/emacs/emacs-26/src/w32.c: In function 'globals_of_w32':
C:/emacs/git/emacs/emacs-26/src/w32.c:9659:26: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, struct _FILETIME *, struct _FILETIME *, struct _FILETIME *, struct _FILETIME *)' {aka 'int (*)(void *, struct _FILETIME *, struct _FILETIME *, struct _FILETIME *, struct _FILETIME *)'} [-Wcast-function-type]
   get_process_times_fn = (GetProcessTimes_Proc)
                          ^
  CC       w32heap.o
C:/emacs/git/emacs/emacs-26/src/w32heap.c: In function 'init_heap':
C:/emacs/git/emacs/emacs-26/src/w32heap.c:284:4: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'void * (*)(ULONG,  void *, SIZE_T,  SIZE_T,  void *, void *)' {aka 'void * (*)(long unsigned int,  void *, long long unsigned int,  long long unsigned int,  void *, void *)'} [-Wcast-function-type]
  = (RtlCreateHeap_Proc) GetProcAddress (hm_ntdll, "RtlCreateHeap");
    ^
  CC       w32proc.o
C:/emacs/git/emacs/emacs-26/src/w32proc.c: In function 'init_timers':
C:/emacs/git/emacs/emacs-26/src/w32proc.c:552:7: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, struct _FILETIME *, struct _FILETIME *, struct _FILETIME *, struct _FILETIME *)' {aka 'int (*)(void *, struct _FILETIME *, struct _FILETIME *, struct _FILETIME *, struct _FILETIME *)'} [-Wcast-function-type]
       (GetThreadTimes_Proc)GetProcAddress (GetModuleHandle ("kernel32.dll"),
       ^
C:/emacs/git/emacs/emacs-26/src/w32proc.c: In function 'sys_kill':
C:/emacs/git/emacs/emacs-26/src/w32proc.c:2693:32: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *)' {aka 'int (*)(void *)'} [-Wcast-function-type]
    s_pfn_Debug_Break_Process = (DebugBreakProcess_Proc)
                                ^
C:/emacs/git/emacs/emacs-26/src/w32proc.c: In function 'w32_compare_strings':
C:/emacs/git/emacs/emacs-26/src/w32proc.c:3612:13: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'int (*)(LCID,  DWORD,  const WCHAR *, int,  const WCHAR *, int)' {aka 'int (*)(long unsigned int,  long unsigned int,  const short unsigned int *, int,  const short unsigned int *, int)'} [-Wcast-function-type]
             (CompareStringW_Proc) GetProcAddress (LoadLibrary ("Unicows.dll"),
             ^




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-06 21:58             ` Paul Eggert
@ 2018-08-11 15:06               ` Andy Moreton
  2018-08-11 19:23                 ` Paul Eggert
  0 siblings, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-11 15:06 UTC (permalink / raw)
  To: emacs-devel

On Mon 06 Aug 2018, Paul Eggert wrote:

> Andy Moreton wrote:
>> I was hoping you could provide more background, as you are are shown as
>> the most recent committer of almost every line of configure.ac related
>> to warnings.
>
> Yes, I adapt this stuff for Emacs. However, it sounds like the part you want
> changed comes from a part of Gnulib that I do not know as well.
>
>> Is this problem arising from use of the gnulib manywarnings module ? If
>> so, why do we use it and not the simpler gnuslib warnings module ?
>
> The warnings module would require the hand-maintained Emacs source code to
> list the exact set of warnings that it wants, which would be a pain to
> maintain as the set commonly changes after each GCC release. The manywarnings
> module maintains such a list for us, which is simpler for Emacs proper (and
> allows us to share this mutating list among several GNU projects). The Emacs
> configure.ac tailors the Gnulib list a bit, but mostly leaves it alone; this
> is simpler for Emacs than maintaining its own sort-of-copy of the list by
> hand.

Using the manywarnings module still requires emacs to add new warnings to
the nw list every time gcc is upgraded, so I don't think that is less
work.

The manywarnings list also lists every conceivable warning, including
-Wall and -Wextra (why specify so many explicitly then?) and some that
are specific to C++ (why list them at all?).

It woudl surely be simpler to use _Wall -Wextra and a limited number of
additional warnings that know to be useful, rather than checking if every
warning is supported, even if they are unused and pointless.

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 15:02             ` Andy Moreton
@ 2018-08-11 17:15               ` Eli Zaretskii
  2018-08-11 18:13                 ` Andy Moreton
  0 siblings, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-11 17:15 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Sat, 11 Aug 2018 16:02:03 +0100
> 
> On Sat 11 Aug 2018, Eli Zaretskii wrote:
> 
> >> From: Andy Moreton <andrewjmoreton@gmail.com>
> >> Date: Sat, 11 Aug 2018 11:41:20 +0100
> >> 
> >> > OK, I've now done so.  Andrew, please see if this fixes the original
> >> > problem with this warning.
> >> 
> >> Yes, that ha removed that batch of warnings.
> >
> > Thanks for testing.
> >
> >> There are still other warnings: one from -Wformat-overflow and 78 from
> >> -Wcast-function-type.
> >
> > Can you show the warnings from -Wcast-function-type?
> 
> Here are the warnings from commit ec6f588940e5, built with gcc 8.2.0.
> Mostly this seems to be GetProcAddress results, where it complains that
> FARPROC and the desired fuinction type don't match. The gcc manual says
> that casting via "void (*)(void)" can be used to pacify the warning.
> 
> 
>   CC       dynlib.o
> C:/emacs/git/emacs/emacs-26/src/dynlib.c: In function 'dynlib_addr':
> C:/emacs/git/emacs/emacs-26/src/dynlib.c:160:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(DWORD,  const CHAR *, struct HINSTANCE__ **)' {aka 'int (*)(long unsigned int,  const char *, struct HINSTANCE__ **)'} [-Wcast-function-type]
>       (GetModuleHandleExA_Proc) GetProcAddress (hm_kernel32,
>       ^

Does it help to take the GetProcAddress call in parentheses, like
this:

	  s_pfn_Get_Module_HandleExA =
	    (GetModuleHandleExA_Proc) (GetProcAddress (hm_kernel32,
						       "GetModuleHandleExA"));

?

If this doesn't help, what about removing the cast entirely?

In any case, I think it's a GCC bug: it thinks we are type-casting the
function being called, which is GetProcAddress, whereas what we really
want to do is cast the _value_ the function returns.

Thanks.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 17:15               ` Eli Zaretskii
@ 2018-08-11 18:13                 ` Andy Moreton
  2018-08-11 18:26                   ` Eli Zaretskii
  0 siblings, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-11 18:13 UTC (permalink / raw)
  To: emacs-devel

On Sat 11 Aug 2018, Eli Zaretskii wrote:

>> From: Andy Moreton <andrewjmoreton@gmail.com>
>> Date: Sat, 11 Aug 2018 16:02:03 +0100
>> 
>> On Sat 11 Aug 2018, Eli Zaretskii wrote:
>> 
>> >> From: Andy Moreton <andrewjmoreton@gmail.com>
>> >> Date: Sat, 11 Aug 2018 11:41:20 +0100
>> >> 
>> >> > OK, I've now done so.  Andrew, please see if this fixes the original
>> >> > problem with this warning.
>> >> 
>> >> Yes, that ha removed that batch of warnings.
>> >
>> > Thanks for testing.
>> >
>> >> There are still other warnings: one from -Wformat-overflow and 78 from
>> >> -Wcast-function-type.
>> >
>> > Can you show the warnings from -Wcast-function-type?
>> 
>> Here are the warnings from commit ec6f588940e5, built with gcc 8.2.0.
>> Mostly this seems to be GetProcAddress results, where it complains that
>> FARPROC and the desired fuinction type don't match. The gcc manual says
>> that casting via "void (*)(void)" can be used to pacify the warning.
>> 
>> 
>>   CC       dynlib.o
>> C:/emacs/git/emacs/emacs-26/src/dynlib.c: In function 'dynlib_addr':
>> C:/emacs/git/emacs/emacs-26/src/dynlib.c:160:6: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(DWORD,  const CHAR *, struct HINSTANCE__ **)' {aka 'int (*)(long unsigned int,  const char *, struct HINSTANCE__ **)'} [-Wcast-function-type]
>>       (GetModuleHandleExA_Proc) GetProcAddress (hm_kernel32,
>>       ^
>
> Does it help to take the GetProcAddress call in parentheses, like
> this:
>
> 	  s_pfn_Get_Module_HandleExA =
> 	    (GetModuleHandleExA_Proc) (GetProcAddress (hm_kernel32,
> 						       "GetModuleHandleExA"));

Doesn't help - gcc still warns.

> If this doesn't help, what about removing the cast entirely?

Also still warns. This does work:

	  s_pfn_Get_Module_HandleExA =
	    (GetModuleHandleExA_Proc) (void (*)(void))
            GetProcAddress (hm_kernel32, "GetModuleHandleExA");

This is sliughtly less ugly and also pacifies the warning:

#define FN_PTR_CAST(fnptrtype, fnptr)                   \
          ((fnptrtype) (void (*)(void)) (fnptr))

	  s_pfn_Get_Module_HandleExA =
            FN_PTR_CAST(GetModuleHandleExA_Proc,
                        GetProcAddress (hm_kernel32, "GetModuleHandleExA"));


> In any case, I think it's a GCC bug: it thinks we are type-casting the
> function being called, which is GetProcAddress, whereas what we really
> want to do is cast the _value_ the function returns.

I disagree. GetProcAddress returns FARPROC, and GetModuleHandleExA_Proc
has a different signature. It is valid to warn about this.

    AndyM





^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 18:13                 ` Andy Moreton
@ 2018-08-11 18:26                   ` Eli Zaretskii
  2018-08-11 18:36                     ` Andy Moreton
  0 siblings, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-11 18:26 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Sat, 11 Aug 2018 19:13:00 +0100
> 
> > Does it help to take the GetProcAddress call in parentheses, like
> > this:
> >
> > 	  s_pfn_Get_Module_HandleExA =
> > 	    (GetModuleHandleExA_Proc) (GetProcAddress (hm_kernel32,
> > 						       "GetModuleHandleExA"));
> 
> Doesn't help - gcc still warns.
> 
> > If this doesn't help, what about removing the cast entirely?
> 
> Also still warns. This does work:
> 
> 	  s_pfn_Get_Module_HandleExA =
> 	    (GetModuleHandleExA_Proc) (void (*)(void))
>             GetProcAddress (hm_kernel32, "GetModuleHandleExA");
> 
> This is sliughtly less ugly and also pacifies the warning:
> 
> #define FN_PTR_CAST(fnptrtype, fnptr)                   \
>           ((fnptrtype) (void (*)(void)) (fnptr))
> 
> 	  s_pfn_Get_Module_HandleExA =
>             FN_PTR_CAST(GetModuleHandleExA_Proc,
>                         GetProcAddress (hm_kernel32, "GetModuleHandleExA"));

I'd rather disable the warning around the code which uses these casts.
Or maybe we should introduce our ownj get_proc_address, which returns
a (void (*)(void)) pointer.  But that's not for emacs-26, sorry.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 18:26                   ` Eli Zaretskii
@ 2018-08-11 18:36                     ` Andy Moreton
  2018-08-11 19:04                       ` Andy Moreton
  2018-08-11 19:18                       ` Paul Eggert
  0 siblings, 2 replies; 60+ messages in thread
From: Andy Moreton @ 2018-08-11 18:36 UTC (permalink / raw)
  To: emacs-devel

On Sat 11 Aug 2018, Eli Zaretskii wrote:

>> From: Andy Moreton <andrewjmoreton@gmail.com>
>> Date: Sat, 11 Aug 2018 19:13:00 +0100
>> 
>> > Does it help to take the GetProcAddress call in parentheses, like
>> > this:
>> >
>> > 	  s_pfn_Get_Module_HandleExA =
>> > 	    (GetModuleHandleExA_Proc) (GetProcAddress (hm_kernel32,
>> > 						       "GetModuleHandleExA"));
>> 
>> Doesn't help - gcc still warns.
>> 
>> > If this doesn't help, what about removing the cast entirely?
>> 
>> Also still warns. This does work:
>> 
>> 	  s_pfn_Get_Module_HandleExA =
>> 	    (GetModuleHandleExA_Proc) (void (*)(void))
>>             GetProcAddress (hm_kernel32, "GetModuleHandleExA");
>> 
>> This is sliughtly less ugly and also pacifies the warning:
>> 
>> #define FN_PTR_CAST(fnptrtype, fnptr)                   \
>>           ((fnptrtype) (void (*)(void)) (fnptr))
>> 
>> 	  s_pfn_Get_Module_HandleExA =
>>             FN_PTR_CAST(GetModuleHandleExA_Proc,
>>                         GetProcAddress (hm_kernel32, "GetModuleHandleExA"));
>
> I'd rather disable the warning around the code which uses these casts.
> Or maybe we should introduce our ownj get_proc_address, which returns
> a (void (*)(void)) pointer.  But that's not for emacs-26, sorry.

Given how many source files are involved, for emacs-26 the simplest
thing is simply to disable -Wcast-function-type in configure.ac.

For master we can leave the warning enabled if the GetProcAddress calls
can be fixed to pacify the warning.

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 18:36                     ` Andy Moreton
@ 2018-08-11 19:04                       ` Andy Moreton
  2018-08-11 19:10                         ` Eli Zaretskii
  2018-08-11 19:18                       ` Paul Eggert
  1 sibling, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-11 19:04 UTC (permalink / raw)
  To: emacs-devel

On Sat 11 Aug 2018, Andy Moreton wrote:

> On Sat 11 Aug 2018, Eli Zaretskii wrote:
>
>>> From: Andy Moreton <andrewjmoreton@gmail.com>
>>> Date: Sat, 11 Aug 2018 19:13:00 +0100
>>> 
>>> > Does it help to take the GetProcAddress call in parentheses, like
>>> > this:
>>> >
>>> > 	  s_pfn_Get_Module_HandleExA =
>>> > 	    (GetModuleHandleExA_Proc) (GetProcAddress (hm_kernel32,
>>> > 						       "GetModuleHandleExA"));
>>> 
>>> Doesn't help - gcc still warns.
>>> 
>>> > If this doesn't help, what about removing the cast entirely?
>>> 
>>> Also still warns. This does work:
>>> 
>>> 	  s_pfn_Get_Module_HandleExA =
>>> 	    (GetModuleHandleExA_Proc) (void (*)(void))
>>>             GetProcAddress (hm_kernel32, "GetModuleHandleExA");
>>> 
>>> This is sliughtly less ugly and also pacifies the warning:
>>> 
>>> #define FN_PTR_CAST(fnptrtype, fnptr)                   \
>>>           ((fnptrtype) (void (*)(void)) (fnptr))
>>> 
>>> 	  s_pfn_Get_Module_HandleExA =
>>>             FN_PTR_CAST(GetModuleHandleExA_Proc,
>>>                         GetProcAddress (hm_kernel32, "GetModuleHandleExA"));
>>
>> I'd rather disable the warning around the code which uses these casts.
>> Or maybe we should introduce our ownj get_proc_address, which returns
>> a (void (*)(void)) pointer.  But that's not for emacs-26, sorry.

For the record, with get_proc_address like this:

    typedef void (*VOIDFNPTR)(void);

    VOIDFNPTR
    get_proc_address (HINSTANCE handle, LPCSTR fname)
    {
      return (VOIDFNPTR) GetProcAddress (handle, fname);
    }

Then the following does not trigger the warning:

 	  s_pfn_Get_Module_HandleExA =
	    (GetModuleHandleExA_Proc) get_proc_address (hm_kernel32,
                                                        "GetModuleHandleExA");





^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 19:04                       ` Andy Moreton
@ 2018-08-11 19:10                         ` Eli Zaretskii
  2018-08-14 12:59                           ` Andy Moreton
  0 siblings, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-11 19:10 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Sat, 11 Aug 2018 20:04:26 +0100
> 
> >> Or maybe we should introduce our ownj get_proc_address, which returns
> >> a (void (*)(void)) pointer.  But that's not for emacs-26, sorry.
> 
> For the record, with get_proc_address like this:
> 
>     typedef void (*VOIDFNPTR)(void);
> 
>     VOIDFNPTR
>     get_proc_address (HINSTANCE handle, LPCSTR fname)
>     {
>       return (VOIDFNPTR) GetProcAddress (handle, fname);
>     }
> 
> Then the following does not trigger the warning:
> 
>  	  s_pfn_Get_Module_HandleExA =
> 	    (GetModuleHandleExA_Proc) get_proc_address (hm_kernel32,
>                                                         "GetModuleHandleExA");

Yes, that's what I had in mind, just with a comment explaining why we
need to jump through that particular hoop.

Thanks.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 18:36                     ` Andy Moreton
  2018-08-11 19:04                       ` Andy Moreton
@ 2018-08-11 19:18                       ` Paul Eggert
  2018-08-15 15:53                         ` Andy Moreton
  1 sibling, 1 reply; 60+ messages in thread
From: Paul Eggert @ 2018-08-11 19:18 UTC (permalink / raw)
  To: emacs-devel

Andy Moreton wrote:
> Given how many source files are involved, for emacs-26 the simplest
> thing is simply to disable -Wcast-function-type in configure.ac.
> 
> For master we can leave the warning enabled if the GetProcAddress calls
> can be fixed to pacify the warning.

If we disable the warning at all, we should do so only in the files that need 
it, as the warning is typically useful.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 15:06               ` Andy Moreton
@ 2018-08-11 19:23                 ` Paul Eggert
  2018-08-11 19:38                   ` Andy Moreton
  0 siblings, 1 reply; 60+ messages in thread
From: Paul Eggert @ 2018-08-11 19:23 UTC (permalink / raw)
  To: Andy Moreton, emacs-devel

Andy Moreton wrote:
> Using the manywarnings module still requires emacs to add new warnings to
> the nw list every time gcc is upgraded, so I don't think that is less
> work.

That work is automated by the admin/merge-gnulib script. So it is less work.

> It woudl surely be simpler to use _Wall -Wextra and a limited number of
> additional warnings that know to be useful

That's how we did things originally, and it was more work that way, because it 
meant each project had to track every new GCC warning that might be useful for 
that project. It's less work overall if we rely on Gnulib's module, which grabs 
almost all GCC warnings (except those that don't seem to be useful in any GNU 
project), and then let each project filter out the relatively few ones that it 
doesn't want.

There is no perfect solution here, but we tried it the way you're suggesting and 
it was more work than what we're doing now.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 19:23                 ` Paul Eggert
@ 2018-08-11 19:38                   ` Andy Moreton
  2018-08-11 20:13                     ` Paul Eggert
  0 siblings, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-11 19:38 UTC (permalink / raw)
  To: emacs-devel

On Sat 11 Aug 2018, Paul Eggert wrote:
> There is no perfect solution here, but we tried it the way you're suggesting
> and it was more work than what we're doing now.

Agreed, but the current solution minimises effort for gnulib imports,
rather than emacs developers, whose machines waste time and energy on
pointless configure checks for warnings.

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 19:38                   ` Andy Moreton
@ 2018-08-11 20:13                     ` Paul Eggert
  0 siblings, 0 replies; 60+ messages in thread
From: Paul Eggert @ 2018-08-11 20:13 UTC (permalink / raw)
  To: Andy Moreton, emacs-devel

Andy Moreton wrote:
> Agreed, but the current solution minimises effort for gnulib imports,
> rather than emacs developers, whose machines waste time and energy on
> pointless configure checks for warnings.

It helps Emacs developers too, not all of whom use the same GCC (or clang) 
version. I care about these warnings more than most, and I don't want to go down 
the rabbit hole of tracking multiple GCC and clang versions by hand in the Emacs 
source code.

To improve 'configure' speed you can cache the results by using './configure 
--cache-file=FOO', as was mentioned elsewhere in this thread. On my platform 
(Ubuntu 18.04 x86-64, Xeon E3-1225 V2), this shrinks 'configure' time from 32.3 
to 4.4 user+system CPU seconds, an 86% savings.

If you can't use the cache for some reason, you can use a command like this:

./configure --disable-gcc-warnings

This avoids the 'configure' warning tests you're worried about, and shrinks my 
'configure' time from 32.3 to 25.8 user+system CPU seconds, a 20% savings. You 
can then build with "make WARN_CFLAGS='-Wall -Whatever'" with your own preferred 
hand-built warning list.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 19:10                         ` Eli Zaretskii
@ 2018-08-14 12:59                           ` Andy Moreton
  2018-08-14 21:20                             ` Andy Moreton
  2018-08-17 14:32                             ` Eli Zaretskii
  0 siblings, 2 replies; 60+ messages in thread
From: Andy Moreton @ 2018-08-14 12:59 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]

On Sat 11 Aug 2018, Eli Zaretskii wrote:

>> From: Andy Moreton <andrewjmoreton@gmail.com>
>> Date: Sat, 11 Aug 2018 20:04:26 +0100
>> 
>> >> Or maybe we should introduce our ownj get_proc_address, which returns
>> >> a (void (*)(void)) pointer.  But that's not for emacs-26, sorry.
>
> Yes, that's what I had in mind, just with a comment explaining why we
> need to jump through that particular hoop.

The attached patch fixes the -Wcast-function-type warnings when building
on Windows MSYS2 64bit (GCC 8.2.0) with "-Og". Theere is one remaining
compiler warning:

C:/emacs/git/emacs/master/src/w32fns.c: In function 'Fw32_read_registry':
C:/emacs/git/emacs/master/src/w32fns.c:10142:21: warning: 'rootkey' may be used uninitialized in this function [-Wmaybe-uninitialized]
   Lisp_Object val = w32_read_registry (NILP (root)
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            ? HKEY_CURRENT_USER
            ~~~~~~~~~~~~~~~~~~~
            : rootkey,
            ~~~~~~~~~~
            key, name);
            ~~~~~~~~~~



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: cast-function-type-warning.patch --]
[-- Type: text/x-patch, Size: 39707 bytes --]

Pacify -Wcast-function-type warnings in GCC 8.1.

	* src/image.c: move attributes into DEF_DLL_FN call.
	* src/dynlib.c (dynlib_addr): Use w32_get_proc_address.
	* src/w32.h:
	(w32_get_proc_address): New function.
	(LOAD_DLL_FN): Use it.
	(DEF_DLL_FN): Allow function attributes after argument
	list. Add function pointer type used by LOAD_DLL_FN.
	* src/w32.c (open_process_token, get_token_information)
	(lookup_account_sid, get_sid_sub_authority)
	(get_sid_sub_authority_count, get_security_info)
	(get_file_security, set_file_security)
	(set_named_security_info)
	(get_security_descriptor_owner, get_security_descriptor_group)
	(get_security_descriptor_dacl, is_valid_sid, equal_sid)
	(get_length_sid, copy_sid, get_native_system_info)
	(get_system_times, create_symbolic_link)
	(is_valid_security_descriptor, convert_sd_to_sddl)
	(convert_sddl_to_sd, get_adapters_info, reg_open_key_ex_w)
	(reg_query_value_ex_w, expand_environment_strings_w)
	(init_environment, create_toolhelp32_snapshot)
	(process32_first, process32_next, open_thread_token)
	(impersonate_self, revert_to_self, get_process_memory_info)
	(get_process_working_set_size, global_memory_status)
	(global_memory_status_ex, init_winsock)
	(maybe_load_unicows_dll, globals_of_w32): Use
	w32_get_proc_address.
	* src/w32fns.c (setup_w32_kbdhook, Ffile_system_info)
	(get_dll_version, w32_reset_stack_overflow_guard)
	(w32_backtrace, globals_of_w32fns): Use w32_get_proc_address.
	* src/w32font.c (get_outline_metrics_w, get_text_metrics_w)
	(get_glyph_outline_w, get_char_width_32_w): Use
	w32_get_proc_address.
	* src/w32heap.c (init_heap): Use w32_get_proc_address.
	* src/w32menu.c (globals_of_w32menu): Use
	w32_get_proc_address.
	* src/w32proc.c (init_timers, sys_kill, w32_compare_strings):
	Use w32_get_proc_address.
	* src/w32uniscribe.c (syms_of_w32uniscribe): Use
	w32_get_proc_address.

diff --git a/src/dynlib.c b/src/dynlib.c
index 53afdafa2d..c4bad3d50b 100644
--- a/src/dynlib.c
+++ b/src/dynlib.c
@@ -156,9 +156,8 @@ dynlib_addr (void *addr, const char **fname, const char **symname)
 	     address we pass to it is not an address of a string, but
 	     an address of a function.  So we don't care about the
 	     Unicode version.  */
-	  s_pfn_Get_Module_HandleExA =
-	    (GetModuleHandleExA_Proc) GetProcAddress (hm_kernel32,
-						      "GetModuleHandleExA");
+	  s_pfn_Get_Module_HandleExA = (GetModuleHandleExA_Proc)
+            w32_get_proc_address (hm_kernel32, "GetModuleHandleExA");
 	}
       if (s_pfn_Get_Module_HandleExA)
 	{
diff --git a/src/image.c b/src/image.c
index 499c1b6aed..7866b9cc46 100644
--- a/src/image.c
+++ b/src/image.c
@@ -5734,7 +5734,7 @@ DEF_DLL_FN (void, png_read_end, (png_structp, png_infop));
 DEF_DLL_FN (void, png_error, (png_structp, png_const_charp));
 
 #  if (PNG_LIBPNG_VER >= 10500)
-DEF_DLL_FN (void, png_longjmp, (png_structp, int)) PNG_NORETURN;
+DEF_DLL_FN (void, png_longjmp, (png_structp, int) PNG_NORETURN);
 DEF_DLL_FN (jmp_buf *, png_set_longjmp_fn,
 	    (png_structp, png_longjmp_ptr, size_t));
 #  endif /* libpng version >= 1.5 */
diff --git a/src/w32.c b/src/w32.c
index ef6047580e..806e59453f 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -576,8 +576,8 @@ open_process_token (HANDLE ProcessHandle,
     {
       g_b_init_open_process_token = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Open_Process_Token =
-        (OpenProcessToken_Proc) GetProcAddress (hm_advapi32, "OpenProcessToken");
+      s_pfn_Open_Process_Token = (OpenProcessToken_Proc)
+        w32_get_proc_address (hm_advapi32, "OpenProcessToken");
     }
   if (s_pfn_Open_Process_Token == NULL)
     {
@@ -608,8 +608,8 @@ get_token_information (HANDLE TokenHandle,
     {
       g_b_init_get_token_information = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Get_Token_Information =
-        (GetTokenInformation_Proc) GetProcAddress (hm_advapi32, "GetTokenInformation");
+      s_pfn_Get_Token_Information = (GetTokenInformation_Proc)
+        w32_get_proc_address (hm_advapi32, "GetTokenInformation");
     }
   if (s_pfn_Get_Token_Information == NULL)
     {
@@ -644,8 +644,8 @@ lookup_account_sid (LPCTSTR lpSystemName,
     {
       g_b_init_lookup_account_sid = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Lookup_Account_Sid =
-        (LookupAccountSid_Proc) GetProcAddress (hm_advapi32, LookupAccountSid_Name);
+      s_pfn_Lookup_Account_Sid = (LookupAccountSid_Proc)
+        w32_get_proc_address (hm_advapi32, LookupAccountSid_Name);
     }
   if (s_pfn_Lookup_Account_Sid == NULL)
     {
@@ -677,9 +677,8 @@ get_sid_sub_authority (PSID pSid, DWORD n)
     {
       g_b_init_get_sid_sub_authority = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Get_Sid_Sub_Authority =
-        (GetSidSubAuthority_Proc) GetProcAddress (
-            hm_advapi32, "GetSidSubAuthority");
+      s_pfn_Get_Sid_Sub_Authority = (GetSidSubAuthority_Proc)
+        w32_get_proc_address (hm_advapi32, "GetSidSubAuthority");
     }
   if (s_pfn_Get_Sid_Sub_Authority == NULL)
     {
@@ -702,9 +701,8 @@ get_sid_sub_authority_count (PSID pSid)
     {
       g_b_init_get_sid_sub_authority_count = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Get_Sid_Sub_Authority_Count =
-        (GetSidSubAuthorityCount_Proc) GetProcAddress (
-            hm_advapi32, "GetSidSubAuthorityCount");
+      s_pfn_Get_Sid_Sub_Authority_Count = (GetSidSubAuthorityCount_Proc)
+        w32_get_proc_address (hm_advapi32, "GetSidSubAuthorityCount");
     }
   if (s_pfn_Get_Sid_Sub_Authority_Count == NULL)
     {
@@ -733,9 +731,8 @@ get_security_info (HANDLE handle,
     {
       g_b_init_get_security_info = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Get_Security_Info =
-        (GetSecurityInfo_Proc) GetProcAddress (
-            hm_advapi32, "GetSecurityInfo");
+      s_pfn_Get_Security_Info = (GetSecurityInfo_Proc)
+        w32_get_proc_address (hm_advapi32, "GetSecurityInfo");
     }
   if (s_pfn_Get_Security_Info == NULL)
     {
@@ -769,9 +766,8 @@ get_file_security (const char *lpFileName,
 	{
 	  g_b_init_get_file_security_w = 1;
 	  hm_advapi32 = LoadLibrary ("Advapi32.dll");
-	  s_pfn_Get_File_SecurityW =
-	    (GetFileSecurityW_Proc) GetProcAddress (hm_advapi32,
-						   "GetFileSecurityW");
+	  s_pfn_Get_File_SecurityW = (GetFileSecurityW_Proc)
+            w32_get_proc_address (hm_advapi32, "GetFileSecurityW");
 	}
       if (s_pfn_Get_File_SecurityW == NULL)
 	{
@@ -791,9 +787,8 @@ get_file_security (const char *lpFileName,
 	{
 	  g_b_init_get_file_security_a = 1;
 	  hm_advapi32 = LoadLibrary ("Advapi32.dll");
-	  s_pfn_Get_File_SecurityA =
-	    (GetFileSecurityA_Proc) GetProcAddress (hm_advapi32,
-						   "GetFileSecurityA");
+	  s_pfn_Get_File_SecurityA = (GetFileSecurityA_Proc)
+            w32_get_proc_address (hm_advapi32, "GetFileSecurityA");
 	}
       if (s_pfn_Get_File_SecurityA == NULL)
 	{
@@ -828,9 +823,8 @@ set_file_security (const char *lpFileName,
 	{
 	  g_b_init_set_file_security_w = 1;
 	  hm_advapi32 = LoadLibrary ("Advapi32.dll");
-	  s_pfn_Set_File_SecurityW =
-	    (SetFileSecurityW_Proc) GetProcAddress (hm_advapi32,
-						    "SetFileSecurityW");
+	  s_pfn_Set_File_SecurityW = (SetFileSecurityW_Proc)
+            w32_get_proc_address (hm_advapi32, "SetFileSecurityW");
 	}
       if (s_pfn_Set_File_SecurityW == NULL)
 	{
@@ -849,9 +843,8 @@ set_file_security (const char *lpFileName,
 	{
 	  g_b_init_set_file_security_a = 1;
 	  hm_advapi32 = LoadLibrary ("Advapi32.dll");
-	  s_pfn_Set_File_SecurityA =
-	    (SetFileSecurityA_Proc) GetProcAddress (hm_advapi32,
-						    "SetFileSecurityA");
+	  s_pfn_Set_File_SecurityA = (SetFileSecurityA_Proc)
+            w32_get_proc_address (hm_advapi32, "SetFileSecurityA");
 	}
       if (s_pfn_Set_File_SecurityA == NULL)
 	{
@@ -889,9 +882,8 @@ set_named_security_info (LPCTSTR lpObjectName,
 	{
 	  g_b_init_set_named_security_info_w = 1;
 	  hm_advapi32 = LoadLibrary ("Advapi32.dll");
-	  s_pfn_Set_Named_Security_InfoW =
-	    (SetNamedSecurityInfoW_Proc) GetProcAddress (hm_advapi32,
-							 "SetNamedSecurityInfoW");
+	  s_pfn_Set_Named_Security_InfoW = (SetNamedSecurityInfoW_Proc)
+            w32_get_proc_address (hm_advapi32, "SetNamedSecurityInfoW");
 	}
       if (s_pfn_Set_Named_Security_InfoW == NULL)
 	{
@@ -911,9 +903,8 @@ set_named_security_info (LPCTSTR lpObjectName,
 	{
 	  g_b_init_set_named_security_info_a = 1;
 	  hm_advapi32 = LoadLibrary ("Advapi32.dll");
-	  s_pfn_Set_Named_Security_InfoA =
-	    (SetNamedSecurityInfoA_Proc) GetProcAddress (hm_advapi32,
-							 "SetNamedSecurityInfoA");
+	  s_pfn_Set_Named_Security_InfoA = (SetNamedSecurityInfoA_Proc)
+            w32_get_proc_address (hm_advapi32, "SetNamedSecurityInfoA");
 	}
       if (s_pfn_Set_Named_Security_InfoA == NULL)
 	{
@@ -943,9 +934,8 @@ get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor,
     {
       g_b_init_get_security_descriptor_owner = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Get_Security_Descriptor_Owner =
-        (GetSecurityDescriptorOwner_Proc) GetProcAddress (
-            hm_advapi32, "GetSecurityDescriptorOwner");
+      s_pfn_Get_Security_Descriptor_Owner = (GetSecurityDescriptorOwner_Proc)
+        w32_get_proc_address (hm_advapi32, "GetSecurityDescriptorOwner");
     }
   if (s_pfn_Get_Security_Descriptor_Owner == NULL)
     {
@@ -972,9 +962,8 @@ get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor,
     {
       g_b_init_get_security_descriptor_group = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Get_Security_Descriptor_Group =
-        (GetSecurityDescriptorGroup_Proc) GetProcAddress (
-            hm_advapi32, "GetSecurityDescriptorGroup");
+      s_pfn_Get_Security_Descriptor_Group = (GetSecurityDescriptorGroup_Proc)
+        w32_get_proc_address (hm_advapi32, "GetSecurityDescriptorGroup");
     }
   if (s_pfn_Get_Security_Descriptor_Group == NULL)
     {
@@ -1002,9 +991,8 @@ get_security_descriptor_dacl (PSECURITY_DESCRIPTOR pSecurityDescriptor,
     {
       g_b_init_get_security_descriptor_dacl = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Get_Security_Descriptor_Dacl =
-        (GetSecurityDescriptorDacl_Proc) GetProcAddress (
-            hm_advapi32, "GetSecurityDescriptorDacl");
+      s_pfn_Get_Security_Descriptor_Dacl = (GetSecurityDescriptorDacl_Proc)
+        w32_get_proc_address (hm_advapi32, "GetSecurityDescriptorDacl");
     }
   if (s_pfn_Get_Security_Descriptor_Dacl == NULL)
     {
@@ -1029,9 +1017,8 @@ is_valid_sid (PSID sid)
     {
       g_b_init_is_valid_sid = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Is_Valid_Sid =
-        (IsValidSid_Proc) GetProcAddress (
-            hm_advapi32, "IsValidSid");
+      s_pfn_Is_Valid_Sid = (IsValidSid_Proc)
+        w32_get_proc_address (hm_advapi32, "IsValidSid");
     }
   if (s_pfn_Is_Valid_Sid == NULL)
     {
@@ -1053,9 +1040,8 @@ equal_sid (PSID sid1, PSID sid2)
     {
       g_b_init_equal_sid = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Equal_Sid =
-        (EqualSid_Proc) GetProcAddress (
-            hm_advapi32, "EqualSid");
+      s_pfn_Equal_Sid = (EqualSid_Proc)
+        w32_get_proc_address (hm_advapi32, "EqualSid");
     }
   if (s_pfn_Equal_Sid == NULL)
     {
@@ -1077,9 +1063,8 @@ get_length_sid (PSID sid)
     {
       g_b_init_get_length_sid = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Get_Length_Sid =
-        (GetLengthSid_Proc) GetProcAddress (
-            hm_advapi32, "GetLengthSid");
+      s_pfn_Get_Length_Sid = (GetLengthSid_Proc)
+        w32_get_proc_address (hm_advapi32, "GetLengthSid");
     }
   if (s_pfn_Get_Length_Sid == NULL)
     {
@@ -1101,9 +1086,8 @@ copy_sid (DWORD destlen, PSID dest, PSID src)
     {
       g_b_init_copy_sid = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Copy_Sid =
-        (CopySid_Proc) GetProcAddress (
-            hm_advapi32, "CopySid");
+      s_pfn_Copy_Sid = (CopySid_Proc)
+        w32_get_proc_address (hm_advapi32, "CopySid");
     }
   if (s_pfn_Copy_Sid == NULL)
     {
@@ -1127,9 +1111,9 @@ get_native_system_info (LPSYSTEM_INFO lpSystemInfo)
       if (g_b_init_get_native_system_info == 0)
 	{
 	  g_b_init_get_native_system_info = 1;
-	  s_pfn_Get_Native_System_Info =
-	    (GetNativeSystemInfo_Proc)GetProcAddress (GetModuleHandle ("kernel32.dll"),
-						      "GetNativeSystemInfo");
+	  s_pfn_Get_Native_System_Info = (GetNativeSystemInfo_Proc)
+            w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                                  "GetNativeSystemInfo");
 	}
       if (s_pfn_Get_Native_System_Info != NULL)
 	s_pfn_Get_Native_System_Info (lpSystemInfo);
@@ -1151,9 +1135,9 @@ get_system_times (LPFILETIME lpIdleTime,
   if (g_b_init_get_system_times == 0)
     {
       g_b_init_get_system_times = 1;
-      s_pfn_Get_System_times =
-	(GetSystemTimes_Proc)GetProcAddress (GetModuleHandle ("kernel32.dll"),
-					     "GetSystemTimes");
+      s_pfn_Get_System_times = (GetSystemTimes_Proc)
+        w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                              "GetSystemTimes");
     }
   if (s_pfn_Get_System_times == NULL)
     return FALSE;
@@ -1181,9 +1165,9 @@ create_symbolic_link (LPCSTR lpSymlinkFilename,
       if (g_b_init_create_symbolic_link_w == 0)
 	{
 	  g_b_init_create_symbolic_link_w = 1;
-	  s_pfn_Create_Symbolic_LinkW =
-	    (CreateSymbolicLinkW_Proc)GetProcAddress (GetModuleHandle ("kernel32.dll"),
-						     "CreateSymbolicLinkW");
+	  s_pfn_Create_Symbolic_LinkW = (CreateSymbolicLinkW_Proc)
+            w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                                  "CreateSymbolicLinkW");
 	}
       if (s_pfn_Create_Symbolic_LinkW == NULL)
 	{
@@ -1216,9 +1200,9 @@ create_symbolic_link (LPCSTR lpSymlinkFilename,
       if (g_b_init_create_symbolic_link_a == 0)
 	{
 	  g_b_init_create_symbolic_link_a = 1;
-	  s_pfn_Create_Symbolic_LinkA =
-	    (CreateSymbolicLinkA_Proc)GetProcAddress (GetModuleHandle ("kernel32.dll"),
-						     "CreateSymbolicLinkA");
+	  s_pfn_Create_Symbolic_LinkA = (CreateSymbolicLinkA_Proc)
+            w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                                  "CreateSymbolicLinkA");
 	}
       if (s_pfn_Create_Symbolic_LinkA == NULL)
 	{
@@ -1261,9 +1245,9 @@ is_valid_security_descriptor (PSECURITY_DESCRIPTOR pSecurityDescriptor)
   if (g_b_init_is_valid_security_descriptor == 0)
     {
       g_b_init_is_valid_security_descriptor = 1;
-      s_pfn_Is_Valid_Security_Descriptor_Proc =
-	(IsValidSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
-							"IsValidSecurityDescriptor");
+      s_pfn_Is_Valid_Security_Descriptor_Proc = (IsValidSecurityDescriptor_Proc)
+        w32_get_proc_address (GetModuleHandle ("Advapi32.dll"),
+                              "IsValidSecurityDescriptor");
     }
   if (s_pfn_Is_Valid_Security_Descriptor_Proc == NULL)
     {
@@ -1295,12 +1279,14 @@ convert_sd_to_sddl (PSECURITY_DESCRIPTOR SecurityDescriptor,
       g_b_init_convert_sd_to_sddl = 1;
 #ifdef _UNICODE
       s_pfn_Convert_SD_To_SDDL =
-	(ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
-										  "ConvertSecurityDescriptorToStringSecurityDescriptorW");
+	(ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)
+        w32_get_proc_address (GetModuleHandle ("Advapi32.dll"),
+                              "ConvertSecurityDescriptorToStringSecurityDescriptorW");
 #else
       s_pfn_Convert_SD_To_SDDL =
-	(ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
-										  "ConvertSecurityDescriptorToStringSecurityDescriptorA");
+	(ConvertSecurityDescriptorToStringSecurityDescriptor_Proc)
+        w32_get_proc_address (GetModuleHandle ("Advapi32.dll"),
+                              "ConvertSecurityDescriptorToStringSecurityDescriptorA");
 #endif
     }
   if (s_pfn_Convert_SD_To_SDDL == NULL)
@@ -1338,12 +1324,14 @@ convert_sddl_to_sd (LPCTSTR StringSecurityDescriptor,
       g_b_init_convert_sddl_to_sd = 1;
 #ifdef _UNICODE
       s_pfn_Convert_SDDL_To_SD =
-	(ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
-										  "ConvertStringSecurityDescriptorToSecurityDescriptorW");
+	(ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)
+        w32_get_proc_address (GetModuleHandle ("Advapi32.dll"),
+                              "ConvertStringSecurityDescriptorToSecurityDescriptorW");
 #else
       s_pfn_Convert_SDDL_To_SD =
-	(ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)GetProcAddress (GetModuleHandle ("Advapi32.dll"),
-										  "ConvertStringSecurityDescriptorToSecurityDescriptorA");
+	(ConvertStringSecurityDescriptorToSecurityDescriptor_Proc)
+        w32_get_proc_address (GetModuleHandle ("Advapi32.dll"),
+                              "ConvertStringSecurityDescriptorToSecurityDescriptorA");
 #endif
     }
   if (s_pfn_Convert_SDDL_To_SD == NULL)
@@ -1375,7 +1363,7 @@ get_adapters_info (PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
       hm_iphlpapi = LoadLibrary ("Iphlpapi.dll");
       if (hm_iphlpapi)
 	s_pfn_Get_Adapters_Info = (GetAdaptersInfo_Proc)
-	  GetProcAddress (hm_iphlpapi, "GetAdaptersInfo");
+	  w32_get_proc_address (hm_iphlpapi, "GetAdaptersInfo");
     }
   if (s_pfn_Get_Adapters_Info == NULL)
     return ERROR_NOT_SUPPORTED;
@@ -1398,7 +1386,7 @@ reg_open_key_ex_w (HKEY hkey, LPCWSTR lpSubKey, DWORD ulOptions,
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
       if (hm_advapi32)
 	s_pfn_Reg_Open_Key_Ex_w = (RegOpenKeyExW_Proc)
-	  GetProcAddress (hm_advapi32, "RegOpenKeyExW");
+	  w32_get_proc_address (hm_advapi32, "RegOpenKeyExW");
     }
   if (s_pfn_Reg_Open_Key_Ex_w == NULL)
     return ERROR_NOT_SUPPORTED;
@@ -1422,7 +1410,7 @@ reg_query_value_ex_w (HKEY hkey, LPCWSTR lpValueName, LPDWORD lpReserved,
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
       if (hm_advapi32)
 	s_pfn_Reg_Query_Value_Ex_w = (RegQueryValueExW_Proc)
-	  GetProcAddress (hm_advapi32, "RegQueryValueExW");
+	  w32_get_proc_address (hm_advapi32, "RegQueryValueExW");
     }
   if (s_pfn_Reg_Query_Value_Ex_w == NULL)
     return ERROR_NOT_SUPPORTED;
@@ -1445,7 +1433,7 @@ expand_environment_strings_w (LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize)
       hm_kernel32 = LoadLibrary ("Kernel32.dll");
       if (hm_kernel32)
 	s_pfn_Expand_Environment_Strings_w = (ExpandEnvironmentStringsW_Proc)
-	  GetProcAddress (hm_kernel32, "ExpandEnvironmentStringsW");
+	  w32_get_proc_address (hm_kernel32, "ExpandEnvironmentStringsW");
     }
   if (s_pfn_Expand_Environment_Strings_w == NULL)
     {
@@ -2807,7 +2795,8 @@ init_environment (char ** argv)
 	   MSIE 5.  */
 	ShGetFolderPath_fn get_folder_path;
 	get_folder_path = (ShGetFolderPath_fn)
-	  GetProcAddress (GetModuleHandle ("shell32.dll"), "SHGetFolderPathA");
+	  w32_get_proc_address (GetModuleHandle ("shell32.dll"),
+                                "SHGetFolderPathA");
 
 	if (get_folder_path != NULL)
 	  {
@@ -6639,8 +6628,8 @@ create_toolhelp32_snapshot (DWORD Flags, DWORD Ignored)
     {
       g_b_init_create_toolhelp32_snapshot = 1;
       s_pfn_Create_Toolhelp32_Snapshot = (CreateToolhelp32Snapshot_Proc)
-	GetProcAddress (GetModuleHandle ("kernel32.dll"),
-			"CreateToolhelp32Snapshot");
+	w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                              "CreateToolhelp32Snapshot");
     }
   if (s_pfn_Create_Toolhelp32_Snapshot == NULL)
     {
@@ -6658,8 +6647,8 @@ process32_first (HANDLE hSnapshot, LPPROCESSENTRY32 lppe)
     {
       g_b_init_process32_first = 1;
       s_pfn_Process32_First = (Process32First_Proc)
-	GetProcAddress (GetModuleHandle ("kernel32.dll"),
-			"Process32First");
+	w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                              "Process32First");
     }
   if (s_pfn_Process32_First == NULL)
     {
@@ -6677,8 +6666,8 @@ process32_next (HANDLE hSnapshot, LPPROCESSENTRY32 lppe)
     {
       g_b_init_process32_next = 1;
       s_pfn_Process32_Next = (Process32Next_Proc)
-	GetProcAddress (GetModuleHandle ("kernel32.dll"),
-			"Process32Next");
+	w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                              "Process32Next");
     }
   if (s_pfn_Process32_Next == NULL)
     {
@@ -6704,8 +6693,8 @@ open_thread_token (HANDLE ThreadHandle,
     {
       g_b_init_open_thread_token = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Open_Thread_Token =
-        (OpenThreadToken_Proc) GetProcAddress (hm_advapi32, "OpenThreadToken");
+      s_pfn_Open_Thread_Token = (OpenThreadToken_Proc)
+        w32_get_proc_address (hm_advapi32, "OpenThreadToken");
     }
   if (s_pfn_Open_Thread_Token == NULL)
     {
@@ -6734,8 +6723,8 @@ impersonate_self (SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
     {
       g_b_init_impersonate_self = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Impersonate_Self =
-        (ImpersonateSelf_Proc) GetProcAddress (hm_advapi32, "ImpersonateSelf");
+      s_pfn_Impersonate_Self = (ImpersonateSelf_Proc)
+        w32_get_proc_address (hm_advapi32, "ImpersonateSelf");
     }
   if (s_pfn_Impersonate_Self == NULL)
     {
@@ -6757,8 +6746,8 @@ revert_to_self (void)
     {
       g_b_init_revert_to_self = 1;
       hm_advapi32 = LoadLibrary ("Advapi32.dll");
-      s_pfn_Revert_To_Self =
-        (RevertToSelf_Proc) GetProcAddress (hm_advapi32, "RevertToSelf");
+      s_pfn_Revert_To_Self = (RevertToSelf_Proc)
+        w32_get_proc_address (hm_advapi32, "RevertToSelf");
     }
   if (s_pfn_Revert_To_Self == NULL)
     {
@@ -6784,7 +6773,7 @@ get_process_memory_info (HANDLE h_proc,
       hm_psapi = LoadLibrary ("Psapi.dll");
       if (hm_psapi)
 	s_pfn_Get_Process_Memory_Info = (GetProcessMemoryInfo_Proc)
-	  GetProcAddress (hm_psapi, "GetProcessMemoryInfo");
+	  w32_get_proc_address (hm_psapi, "GetProcessMemoryInfo");
     }
   if (s_pfn_Get_Process_Memory_Info == NULL)
     {
@@ -6809,8 +6798,8 @@ get_process_working_set_size (HANDLE h_proc,
     {
       g_b_init_get_process_working_set_size = 1;
       s_pfn_Get_Process_Working_Set_Size = (GetProcessWorkingSetSize_Proc)
-	GetProcAddress (GetModuleHandle ("kernel32.dll"),
-			"GetProcessWorkingSetSize");
+	w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                              "GetProcessWorkingSetSize");
     }
   if (s_pfn_Get_Process_Working_Set_Size == NULL)
     {
@@ -6832,8 +6821,8 @@ global_memory_status (MEMORYSTATUS *buf)
     {
       g_b_init_global_memory_status = 1;
       s_pfn_Global_Memory_Status = (GlobalMemoryStatus_Proc)
-	GetProcAddress (GetModuleHandle ("kernel32.dll"),
-			"GlobalMemoryStatus");
+	w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                              "GlobalMemoryStatus");
     }
   if (s_pfn_Global_Memory_Status == NULL)
     {
@@ -6855,8 +6844,8 @@ global_memory_status_ex (MEMORY_STATUS_EX *buf)
     {
       g_b_init_global_memory_status_ex = 1;
       s_pfn_Global_Memory_Status_Ex = (GlobalMemoryStatusEx_Proc)
-	GetProcAddress (GetModuleHandle ("kernel32.dll"),
-			"GlobalMemoryStatusEx");
+	w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                              "GlobalMemoryStatusEx");
     }
   if (s_pfn_Global_Memory_Status_Ex == NULL)
     {
@@ -7428,8 +7417,8 @@ init_winsock (int load_now)
     return TRUE;
 
   pfn_SetHandleInformation
-    = (void *) GetProcAddress (GetModuleHandle ("kernel32.dll"),
-			       "SetHandleInformation");
+    = (void *) w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                                     "SetHandleInformation");
 
   winsock_lib = LoadLibrary ("Ws2_32.dll");
 
@@ -7438,7 +7427,7 @@ init_winsock (int load_now)
       /* dynamically link to socket functions */
 
 #define LOAD_PROC(fn) \
-      if ((pfn_##fn = (void *) GetProcAddress (winsock_lib, #fn)) == NULL) \
+      if ((pfn_##fn = (void *) w32_get_proc_address (winsock_lib, #fn)) == NULL) \
         goto fail;
 
       LOAD_PROC (WSAStartup);
@@ -7473,8 +7462,8 @@ init_winsock (int load_now)
 #undef LOAD_PROC
 
       /* Try loading functions not available before XP.  */
-      pfn_getaddrinfo = (void *) GetProcAddress (winsock_lib, "getaddrinfo");
-      pfn_freeaddrinfo = (void *) GetProcAddress (winsock_lib, "freeaddrinfo");
+      pfn_getaddrinfo = (void *) w32_get_proc_address (winsock_lib, "getaddrinfo");
+      pfn_freeaddrinfo = (void *) w32_get_proc_address (winsock_lib, "freeaddrinfo");
       /* Paranoia: these two functions should go together, so if one
 	 is absent, we cannot use the other.  */
       if (pfn_getaddrinfo == NULL)
@@ -9892,10 +9881,10 @@ maybe_load_unicows_dll (void)
 	     pointers, and assign the correct addresses to these
 	     pointers at program startup (see emacs.c, which calls
 	     this function early on).  */
-	  pMultiByteToWideChar =
-	    (MultiByteToWideChar_Proc)GetProcAddress (ret, "MultiByteToWideChar");
-	  pWideCharToMultiByte =
-	    (WideCharToMultiByte_Proc)GetProcAddress (ret, "WideCharToMultiByte");
+	  pMultiByteToWideChar = (MultiByteToWideChar_Proc)
+            w32_get_proc_address (ret, "MultiByteToWideChar");
+	  pWideCharToMultiByte = (WideCharToMultiByte_Proc)
+            w32_get_proc_address (ret, "WideCharToMultiByte");
           multiByteToWideCharFlags = MB_ERR_INVALID_CHARS;
 	  return ret;
 	}
@@ -9946,7 +9935,7 @@ globals_of_w32 (void)
   HMODULE kernel32 = GetModuleHandle ("kernel32.dll");
 
   get_process_times_fn = (GetProcessTimes_Proc)
-    GetProcAddress (kernel32, "GetProcessTimes");
+    w32_get_proc_address (kernel32, "GetProcessTimes");
 
   DEFSYM (QCloaded_from, ":loaded-from");
 
diff --git a/src/w32.h b/src/w32.h
index fe8689a07b..c493c0325b 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -164,6 +164,10 @@ extern void reset_standard_handles (int in, int out,
 /* Return the string resource associated with KEY of type TYPE.  */
 extern LPBYTE w32_get_resource (const char * key, LPDWORD type);
 
+/* Load a function from a DLL.  Defined in this file.  */
+typedef void (* VOIDFNPTR) (void);
+INLINE VOIDFNPTR w32_get_proc_address (HINSTANCE handle, LPCSTR fname);
+
 extern void release_listen_threads (void);
 extern void init_ntproc (int);
 extern void term_ntproc (int);
@@ -241,14 +245,30 @@ extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p,
                                   const void* buf, size_t sz);
 #endif /* HAVE_GNUTLS */
 
-/* Definine a function that will be loaded from a DLL.  */
-#define DEF_DLL_FN(type, func, args) static type (FAR CDECL *fn_##func) args
+
+
+/* Load a function address from a DLL. Cast the result via "VOIDFNPTR"
+   to pacify -Wcast-function-type in GCC 8.1.  */
+INLINE VOIDFNPTR
+w32_get_proc_address (HINSTANCE handle, LPCSTR fname)
+{
+  return (VOIDFNPTR) GetProcAddress (handle, fname);
+}
+
+/* Define a function that will be loaded from a DLL.  The variable
+   arguments should contain the argument list for the function, and
+   optionally be followed by function attributes.  For example:
+   DEF_DLL_FN (void, png_longjmp, (png_structp, int) PNG_NORETURN);
+  */
+#define DEF_DLL_FN(type, func, ...)                     \
+  typedef type (CDECL *W32_PFN_##func) __VA_ARGS__;     \
+  static W32_PFN_##func fn_##func
 
 /* Load a function from the DLL.  */
 #define LOAD_DLL_FN(lib, func)						\
   do									\
     {									\
-      fn_##func = (void *) GetProcAddress (lib, #func);			\
+      fn_##func = (W32_PFN_##func) w32_get_proc_address (lib, #func);   \
       if (!fn_##func)							\
 	return false;							\
     }									\
diff --git a/src/w32fns.c b/src/w32fns.c
index 8d5293c1af..ecef3621f2 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -2640,7 +2640,7 @@ setup_w32_kbdhook (void)
   if (w32_kbdhook_active)
     {
       IsDebuggerPresent_Proc is_debugger_present = (IsDebuggerPresent_Proc)
-	GetProcAddress (GetModuleHandle ("kernel32.dll"), "IsDebuggerPresent");
+	w32_get_proc_address (GetModuleHandle ("kernel32.dll"), "IsDebuggerPresent");
       if (is_debugger_present && is_debugger_present ())
 	return;
     }
@@ -2655,7 +2655,7 @@ setup_w32_kbdhook (void)
 	 (https://support.microsoft.com/en-us/kb/124103) is used for
 	 NT 4 systems.  */
       GetConsoleWindow_Proc get_console = (GetConsoleWindow_Proc)
-	GetProcAddress (GetModuleHandle ("kernel32.dll"), "GetConsoleWindow");
+	w32_get_proc_address (GetModuleHandle ("kernel32.dll"), "GetConsoleWindow");
 
       if (get_console != NULL)
 	kbdhook.console = get_console ();
@@ -9117,9 +9117,9 @@ DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0,
   {
     HMODULE hKernel = GetModuleHandle ("kernel32");
     GetDiskFreeSpaceExW_Proc pfn_GetDiskFreeSpaceExW =
-      (GetDiskFreeSpaceExW_Proc) GetProcAddress (hKernel, "GetDiskFreeSpaceExW");
+      (GetDiskFreeSpaceExW_Proc) w32_get_proc_address (hKernel, "GetDiskFreeSpaceExW");
     GetDiskFreeSpaceExA_Proc pfn_GetDiskFreeSpaceExA =
-      (GetDiskFreeSpaceExA_Proc) GetProcAddress (hKernel, "GetDiskFreeSpaceExA");
+      (GetDiskFreeSpaceExA_Proc) w32_get_proc_address (hKernel, "GetDiskFreeSpaceExA");
     bool have_pfn_GetDiskFreeSpaceEx =
       ((w32_unicode_filenames && pfn_GetDiskFreeSpaceExW)
        || (!w32_unicode_filenames && pfn_GetDiskFreeSpaceExA));
@@ -9694,8 +9694,8 @@ get_dll_version (const char *dll_name)
 
   if (hdll)
     {
-      DLLGETVERSIONPROC pDllGetVersion
-	= (DLLGETVERSIONPROC) GetProcAddress (hdll, "DllGetVersion");
+      DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)
+        w32_get_proc_address (hdll, "DllGetVersion");
 
       if (pDllGetVersion)
 	{
@@ -10662,9 +10662,8 @@ void
 w32_reset_stack_overflow_guard (void)
 {
   if (resetstkoflw == NULL)
-    resetstkoflw =
-      (_resetstkoflw_proc)GetProcAddress (GetModuleHandle ("msvcrt.dll"),
-					  "_resetstkoflw");
+    resetstkoflw = (_resetstkoflw_proc)
+      w32_get_proc_address (GetModuleHandle ("msvcrt.dll"), "_resetstkoflw");
   /* We ignore the return value.  If _resetstkoflw fails, the next
      stack overflow will crash the program.  */
   if (resetstkoflw != NULL)
@@ -10738,9 +10737,8 @@ w32_backtrace (void **buffer, int limit)
   if (!s_pfn_CaptureStackBackTrace)
     {
       hm_kernel32 = LoadLibrary ("Kernel32.dll");
-      s_pfn_CaptureStackBackTrace =
-	(CaptureStackBackTrace_proc) GetProcAddress (hm_kernel32,
-						     "RtlCaptureStackBackTrace");
+      s_pfn_CaptureStackBackTrace = (CaptureStackBackTrace_proc)
+        w32_get_proc_address (hm_kernel32, "RtlCaptureStackBackTrace");
     }
   if (s_pfn_CaptureStackBackTrace)
     return s_pfn_CaptureStackBackTrace (0, min (BACKTRACE_LIMIT_MAX, limit),
@@ -10873,29 +10871,29 @@ globals_of_w32fns (void)
     it dynamically.  Do it once, here, instead of every time it is used.
   */
   track_mouse_event_fn = (TrackMouseEvent_Proc)
-    GetProcAddress (user32_lib, "TrackMouseEvent");
+    w32_get_proc_address (user32_lib, "TrackMouseEvent");
 
   monitor_from_point_fn = (MonitorFromPoint_Proc)
-    GetProcAddress (user32_lib, "MonitorFromPoint");
+    w32_get_proc_address (user32_lib, "MonitorFromPoint");
   get_monitor_info_fn = (GetMonitorInfo_Proc)
-    GetProcAddress (user32_lib, "GetMonitorInfoA");
+    w32_get_proc_address (user32_lib, "GetMonitorInfoA");
   monitor_from_window_fn = (MonitorFromWindow_Proc)
-    GetProcAddress (user32_lib, "MonitorFromWindow");
+    w32_get_proc_address (user32_lib, "MonitorFromWindow");
   enum_display_monitors_fn = (EnumDisplayMonitors_Proc)
-    GetProcAddress (user32_lib, "EnumDisplayMonitors");
+    w32_get_proc_address (user32_lib, "EnumDisplayMonitors");
   get_title_bar_info_fn = (GetTitleBarInfo_Proc)
-    GetProcAddress (user32_lib, "GetTitleBarInfo");
+    w32_get_proc_address (user32_lib, "GetTitleBarInfo");
 
   {
     HMODULE imm32_lib = GetModuleHandle ("imm32.dll");
     get_composition_string_fn = (ImmGetCompositionString_Proc)
-      GetProcAddress (imm32_lib, "ImmGetCompositionStringW");
+      w32_get_proc_address (imm32_lib, "ImmGetCompositionStringW");
     get_ime_context_fn = (ImmGetContext_Proc)
-      GetProcAddress (imm32_lib, "ImmGetContext");
+      w32_get_proc_address (imm32_lib, "ImmGetContext");
     release_ime_context_fn = (ImmReleaseContext_Proc)
-      GetProcAddress (imm32_lib, "ImmReleaseContext");
+      w32_get_proc_address (imm32_lib, "ImmReleaseContext");
     set_ime_composition_window_fn = (ImmSetCompositionWindow_Proc)
-      GetProcAddress (imm32_lib, "ImmSetCompositionWindow");
+      w32_get_proc_address (imm32_lib, "ImmSetCompositionWindow");
   }
 
   except_code = 0;
diff --git a/src/w32font.c b/src/w32font.c
index c2f5dc3746..719b346577 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -153,7 +153,7 @@ get_outline_metrics_w(HDC hdc, UINT cbData, LPOUTLINETEXTMETRICW lpotmw)
       hm_unicows = w32_load_unicows_or_gdi32 ();
       if (hm_unicows)
 	s_pfn_Get_Outline_Text_MetricsW = (GetOutlineTextMetricsW_Proc)
-	  GetProcAddress (hm_unicows, "GetOutlineTextMetricsW");
+	  w32_get_proc_address (hm_unicows, "GetOutlineTextMetricsW");
     }
   eassert (s_pfn_Get_Outline_Text_MetricsW != NULL);
   return s_pfn_Get_Outline_Text_MetricsW (hdc, cbData, lpotmw);
@@ -170,7 +170,7 @@ get_text_metrics_w(HDC hdc, LPTEXTMETRICW lptmw)
       hm_unicows = w32_load_unicows_or_gdi32 ();
       if (hm_unicows)
 	s_pfn_Get_Text_MetricsW = (GetTextMetricsW_Proc)
-	  GetProcAddress (hm_unicows, "GetTextMetricsW");
+	  w32_get_proc_address (hm_unicows, "GetTextMetricsW");
     }
   eassert (s_pfn_Get_Text_MetricsW != NULL);
   return s_pfn_Get_Text_MetricsW (hdc, lptmw);
@@ -188,7 +188,7 @@ get_glyph_outline_w (HDC hdc, UINT uChar, UINT uFormat, LPGLYPHMETRICS lpgm,
       hm_unicows = w32_load_unicows_or_gdi32 ();
       if (hm_unicows)
 	s_pfn_Get_Glyph_OutlineW = (GetGlyphOutlineW_Proc)
-	  GetProcAddress (hm_unicows, "GetGlyphOutlineW");
+	  w32_get_proc_address (hm_unicows, "GetGlyphOutlineW");
     }
   eassert (s_pfn_Get_Glyph_OutlineW != NULL);
   return s_pfn_Get_Glyph_OutlineW (hdc, uChar, uFormat, lpgm, cbBuffer,
@@ -206,7 +206,7 @@ get_char_width_32_w (HDC hdc, UINT uFirstChar, UINT uLastChar, LPINT lpBuffer)
       hm_unicows = w32_load_unicows_or_gdi32 ();
       if (hm_unicows)
 	s_pfn_Get_Char_Width_32W = (GetCharWidth32W_Proc)
-	  GetProcAddress (hm_unicows, "GetCharWidth32W");
+	  w32_get_proc_address (hm_unicows, "GetCharWidth32W");
     }
   eassert (s_pfn_Get_Char_Width_32W != NULL);
   return s_pfn_Get_Char_Width_32W (hdc, uFirstChar, uLastChar, lpBuffer);
diff --git a/src/w32heap.c b/src/w32heap.c
index df79f8c2ce..95c1827a59 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -250,7 +250,9 @@ init_heap (void)
 #ifndef MINGW_W64
       /* Set the low-fragmentation heap for OS before Vista.  */
       HMODULE hm_kernel32dll = LoadLibrary ("kernel32.dll");
-      HeapSetInformation_Proc s_pfn_Heap_Set_Information = (HeapSetInformation_Proc) GetProcAddress (hm_kernel32dll, "HeapSetInformation");
+      HeapSetInformation_Proc s_pfn_Heap_Set_Information =
+        (HeapSetInformation_Proc) w32_get_proc_address (hm_kernel32dll,
+                                                        "HeapSetInformation");
       if (s_pfn_Heap_Set_Information != NULL)
 	{
 	  if (s_pfn_Heap_Set_Information ((PVOID) heap,
@@ -281,7 +283,7 @@ init_heap (void)
          in ntdll.dll since XP.  */
       HMODULE hm_ntdll = LoadLibrary ("ntdll.dll");
       RtlCreateHeap_Proc s_pfn_Rtl_Create_Heap
-	= (RtlCreateHeap_Proc) GetProcAddress (hm_ntdll, "RtlCreateHeap");
+	= (RtlCreateHeap_Proc) w32_get_proc_address (hm_ntdll, "RtlCreateHeap");
       /* Specific parameters for the private heap.  */
       RTL_HEAP_PARAMETERS params;
       ZeroMemory (&params, sizeof(params));
diff --git a/src/w32menu.c b/src/w32menu.c
index ece5836498..8fd044cb1a 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -1607,9 +1607,13 @@ globals_of_w32menu (void)
 #ifndef NTGUI_UNICODE
   /* See if Get/SetMenuItemInfo functions are available.  */
   HMODULE user32 = GetModuleHandle ("user32.dll");
-  get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
-  set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
-  unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
-  unicode_message_box = (MessageBoxW_Proc) GetProcAddress (user32, "MessageBoxW");
+  get_menu_item_info = (GetMenuItemInfoA_Proc)
+    w32_get_proc_address (user32, "GetMenuItemInfoA");
+  set_menu_item_info = (SetMenuItemInfoA_Proc)
+    w32_get_proc_address (user32, "SetMenuItemInfoA");
+  unicode_append_menu = (AppendMenuW_Proc)
+    w32_get_proc_address (user32, "AppendMenuW");
+  unicode_message_box = (MessageBoxW_Proc)
+    w32_get_proc_address (user32, "MessageBoxW");
 #endif /* !NTGUI_UNICODE */
 }
diff --git a/src/w32proc.c b/src/w32proc.c
index 61ce157b55..118767827d 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -548,9 +548,8 @@ init_timers (void)
      through a pointer.  */
   s_pfn_Get_Thread_Times = NULL; /* in case dumped Emacs comes with a value */
   if (os_subtype != OS_9X)
-    s_pfn_Get_Thread_Times =
-      (GetThreadTimes_Proc)GetProcAddress (GetModuleHandle ("kernel32.dll"),
-					   "GetThreadTimes");
+    s_pfn_Get_Thread_Times = (GetThreadTimes_Proc)
+      w32_get_proc_address (GetModuleHandle ("kernel32.dll"), "GetThreadTimes");
 
   /* Make sure we start with zeroed out itimer structures, since
      dumping may have left there traces of threads long dead.  */
@@ -2691,8 +2690,8 @@ sys_kill (pid_t pid, int sig)
 	{
 	  g_b_init_debug_break_process = 1;
 	  s_pfn_Debug_Break_Process = (DebugBreakProcess_Proc)
-	    GetProcAddress (GetModuleHandle ("kernel32.dll"),
-			    "DebugBreakProcess");
+	    w32_get_proc_address (GetModuleHandle ("kernel32.dll"),
+                                  "DebugBreakProcess");
 	}
 
       if (s_pfn_Debug_Break_Process == NULL)
@@ -3608,9 +3607,9 @@ w32_compare_strings (const char *s1, const char *s2, char *locname,
     {
       if (os_subtype == OS_9X)
 	{
-	  pCompareStringW =
-            (CompareStringW_Proc) GetProcAddress (LoadLibrary ("Unicows.dll"),
-                                                  "CompareStringW");
+	  pCompareStringW = (CompareStringW_Proc)
+            w32_get_proc_address (LoadLibrary ("Unicows.dll"),
+                                  "CompareStringW");
 	  if (!pCompareStringW)
 	    {
 	      errno = EINVAL;
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index 11bfa5490b..2ca81a4d3a 100644
--- a/src/w32uniscribe.c
+++ b/src/w32uniscribe.c
@@ -1194,11 +1194,11 @@ syms_of_w32uniscribe (void)
   register_font_driver (&uniscribe_font_driver, NULL);
 
   script_get_font_scripts_fn = (ScriptGetFontScriptTags_Proc)
-    GetProcAddress (uniscribe, "ScriptGetFontScriptTags");
+    w32_get_proc_address (uniscribe, "ScriptGetFontScriptTags");
   script_get_font_languages_fn = (ScriptGetFontLanguageTags_Proc)
-    GetProcAddress (uniscribe, "ScriptGetFontLanguageTags");
+    w32_get_proc_address (uniscribe, "ScriptGetFontLanguageTags");
   script_get_font_features_fn = (ScriptGetFontFeatureTags_Proc)
-    GetProcAddress (uniscribe, "ScriptGetFontFeatureTags");
+    w32_get_proc_address (uniscribe, "ScriptGetFontFeatureTags");
   if (script_get_font_scripts_fn
       && script_get_font_languages_fn
       && script_get_font_features_fn)

^ permalink raw reply related	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-14 12:59                           ` Andy Moreton
@ 2018-08-14 21:20                             ` Andy Moreton
  2018-08-14 22:32                               ` Paul Eggert
  2018-08-17 14:32                             ` Eli Zaretskii
  1 sibling, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-14 21:20 UTC (permalink / raw)
  To: emacs-devel

On Tue 14 Aug 2018, Andy Moreton wrote:

> On Sat 11 Aug 2018, Eli Zaretskii wrote:
>
>>> From: Andy Moreton <andrewjmoreton@gmail.com>
>>> Date: Sat, 11 Aug 2018 20:04:26 +0100
>>> 
>>> >> Or maybe we should introduce our ownj get_proc_address, which returns
>>> >> a (void (*)(void)) pointer.  But that's not for emacs-26, sorry.
>>
>> Yes, that's what I had in mind, just with a comment explaining why we
>> need to jump through that particular hoop.
>
> The attached patch fixes the -Wcast-function-type warnings when building
> on Windows MSYS2 64bit (GCC 8.2.0) with "-Og". Theere is one remaining
> compiler warning:
>
> C:/emacs/git/emacs/master/src/w32fns.c: In function 'Fw32_read_registry':
> C:/emacs/git/emacs/master/src/w32fns.c:10142:21: warning: 'rootkey' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    Lisp_Object val = w32_read_registry (NILP (root)
>                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>             ? HKEY_CURRENT_USER
>             ~~~~~~~~~~~~~~~~~~~
>             : rootkey,
>             ~~~~~~~~~~
>             key, name);
>             ~~~~~~~~~~

There is also one function cast warning from gnulib code:

C:/emacs/git/emacs/master/lib/gettimeofday.c: In function 'initialize':
C:/emacs/git/emacs/master/lib/gettimeofday.c:48:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'void (*)(FILETIME *)' {aka 'void (*)(struct _FILETIME *)'} [-Wcast-function-type]
         (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");
         ^




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-14 21:20                             ` Andy Moreton
@ 2018-08-14 22:32                               ` Paul Eggert
  2018-08-17 14:33                                 ` Eli Zaretskii
  2018-08-18 16:09                                 ` Bruno Haible
  0 siblings, 2 replies; 60+ messages in thread
From: Paul Eggert @ 2018-08-14 22:32 UTC (permalink / raw)
  To: Andy Moreton, Gnulib bugs; +Cc: emacs-devel

On 08/14/2018 02:20 PM, Andy Moreton wrote:
> There is also one function cast warning from gnulib code:
> C:/emacs/git/emacs/master/lib/gettimeofday.c: In function 'initialize':
> C:/emacs/git/emacs/master/lib/gettimeofday.c:48:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'void (*)(FILETIME *)' {aka 'void (*)(struct _FILETIME *)'} [-Wcast-function-type]
>           (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");
>           ^
>

Forwarding this snippet to bug-gnulib so that Bruno Haible can see it, 
as he's the MS-Windows expert. Bruno, the original email is here:

https://lists.gnu.org/r/emacs-devel/2018-08/msg00468.html




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-11 19:18                       ` Paul Eggert
@ 2018-08-15 15:53                         ` Andy Moreton
  2018-08-16 21:05                           ` Paul Eggert
  2018-08-17 14:34                           ` Eli Zaretskii
  0 siblings, 2 replies; 60+ messages in thread
From: Andy Moreton @ 2018-08-15 15:53 UTC (permalink / raw)
  To: emacs-devel

On Sat 11 Aug 2018, Paul Eggert wrote:

> Andy Moreton wrote:
>> Given how many source files are involved, for emacs-26 the simplest
>> thing is simply to disable -Wcast-function-type in configure.ac.
>>
>> For master we can leave the warning enabled if the GetProcAddress calls
>> can be fixed to pacify the warning.
>
> If we disable the warning at all, we should do so only in the files that need
> it, as the warning is typically useful.

I have posted a patch for master to pacify gcc:
http://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00451.html

Eli has indicated that something like this is too intrusive for emacs-26:
http://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00351.html

I agree that the warning is useful, but only if genuine warnings are
visible amid a large number of false positives.

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-15 15:53                         ` Andy Moreton
@ 2018-08-16 21:05                           ` Paul Eggert
  2018-08-17 14:34                           ` Eli Zaretskii
  1 sibling, 0 replies; 60+ messages in thread
From: Paul Eggert @ 2018-08-16 21:05 UTC (permalink / raw)
  To: Andy Moreton, emacs-devel

Andy Moreton wrote:
> I have posted a patch for master to pacify gcc:
> http://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00451.html
> 
> Eli has indicated that something like this is too intrusive for emacs-26:
> http://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00351.html

A cursory look at your patch suggests that it should be OK for master. However, 
it affects only MS-Windows-specific code which I'm not the best guy to judge.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-14 12:59                           ` Andy Moreton
  2018-08-14 21:20                             ` Andy Moreton
@ 2018-08-17 14:32                             ` Eli Zaretskii
  2018-08-17 15:21                               ` Andy Moreton
  1 sibling, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-17 14:32 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Tue, 14 Aug 2018 13:59:08 +0100
> 
> The attached patch fixes the -Wcast-function-type warnings when building
> on Windows MSYS2 64bit (GCC 8.2.0) with "-Og". Theere is one remaining
> compiler warning:
> 
> C:/emacs/git/emacs/master/src/w32fns.c: In function 'Fw32_read_registry':
> C:/emacs/git/emacs/master/src/w32fns.c:10142:21: warning: 'rootkey' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    Lisp_Object val = w32_read_registry (NILP (root)
>                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>             ? HKEY_CURRENT_USER
>             ~~~~~~~~~~~~~~~~~~~
>             : rootkey,
>             ~~~~~~~~~~
>             key, name);
>             ~~~~~~~~~~

Thanks, pushed to the master branch.  I just made the new function's
name a bit shorter.




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-14 22:32                               ` Paul Eggert
@ 2018-08-17 14:33                                 ` Eli Zaretskii
  2018-08-18 16:09                                 ` Bruno Haible
  1 sibling, 0 replies; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-17 14:33 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib, andrewjmoreton, emacs-devel

Ping!

> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Tue, 14 Aug 2018 15:32:44 -0700
> Cc: emacs-devel@gnu.org
> 
> On 08/14/2018 02:20 PM, Andy Moreton wrote:
> > There is also one function cast warning from gnulib code:
> > C:/emacs/git/emacs/master/lib/gettimeofday.c: In function 'initialize':
> > C:/emacs/git/emacs/master/lib/gettimeofday.c:48:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'void (*)(FILETIME *)' {aka 'void (*)(struct _FILETIME *)'} [-Wcast-function-type]
> >           (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");
> >           ^
> >
> 
> Forwarding this snippet to bug-gnulib so that Bruno Haible can see it, 
> as he's the MS-Windows expert. Bruno, the original email is here:
> 
> https://lists.gnu.org/r/emacs-devel/2018-08/msg00468.html
> 
> 
> 



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-15 15:53                         ` Andy Moreton
  2018-08-16 21:05                           ` Paul Eggert
@ 2018-08-17 14:34                           ` Eli Zaretskii
  1 sibling, 0 replies; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-17 14:34 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Wed, 15 Aug 2018 16:53:43 +0100
> 
> > If we disable the warning at all, we should do so only in the files that need
> > it, as the warning is typically useful.
> 
> I have posted a patch for master to pacify gcc:
> http://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00451.html
> 
> Eli has indicated that something like this is too intrusive for emacs-26:
> http://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00351.html
> 
> I agree that the warning is useful, but only if genuine warnings are
> visible amid a large number of false positives.

Maybe we should disable it on emacs-26 only for w32?  All of the
warnings are in w32-specific code.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-17 14:32                             ` Eli Zaretskii
@ 2018-08-17 15:21                               ` Andy Moreton
  2018-08-17 19:45                                 ` Eli Zaretskii
  0 siblings, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-17 15:21 UTC (permalink / raw)
  To: emacs-devel

On Fri 17 Aug 2018, Eli Zaretskii wrote:

>> From: Andy Moreton <andrewjmoreton@gmail.com>
>> Date: Tue, 14 Aug 2018 13:59:08 +0100
>> 
>> The attached patch fixes the -Wcast-function-type warnings when building
>> on Windows MSYS2 64bit (GCC 8.2.0) with "-Og". Theere is one remaining
>> compiler warning:
>> 
>> C:/emacs/git/emacs/master/src/w32fns.c: In function 'Fw32_read_registry':
>> C:/emacs/git/emacs/master/src/w32fns.c:10142:21: warning: 'rootkey' may be used uninitialized in this function [-Wmaybe-uninitialized]
>>    Lisp_Object val = w32_read_registry (NILP (root)
>>                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>             ? HKEY_CURRENT_USER
>>             ~~~~~~~~~~~~~~~~~~~
>>             : rootkey,
>>             ~~~~~~~~~~
>>             key, name);
>>             ~~~~~~~~~~
>
> Thanks, pushed to the master branch.  I just made the new function's
> name a bit shorter.

Thanks. The warning shown above can be fixed with this patch:

diff --git a/src/w32fns.c b/src/w32fns.c
index c32868fa69..0ad5575e6f 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -10125,7 +10125,7 @@ to be converted to forward slashes by the caller.  */)
   CHECK_STRING (key);
   CHECK_STRING (name);
 
-  HKEY rootkey;
+  HKEY rootkey UNINIT;
   if (EQ (root, QHKCR))
     rootkey = HKEY_CLASSES_ROOT;
   else if (EQ (root, QHKCU))




^ permalink raw reply related	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-17 15:21                               ` Andy Moreton
@ 2018-08-17 19:45                                 ` Eli Zaretskii
  2018-08-17 21:33                                   ` Andy Moreton
  0 siblings, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-17 19:45 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Fri, 17 Aug 2018 16:21:24 +0100
> 
> >> C:/emacs/git/emacs/master/src/w32fns.c: In function 'Fw32_read_registry':
> >> C:/emacs/git/emacs/master/src/w32fns.c:10142:21: warning: 'rootkey' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >>    Lisp_Object val = w32_read_registry (NILP (root)
> >>                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >>             ? HKEY_CURRENT_USER
> >>             ~~~~~~~~~~~~~~~~~~~
> >>             : rootkey,
> >>             ~~~~~~~~~~
> >>             key, name);
> >>             ~~~~~~~~~~
> >
> > Thanks, pushed to the master branch.  I just made the new function's
> > name a bit shorter.
> 
> Thanks. The warning shown above can be fixed with this patch:

Thanks, but I prefer using UNINIT only where no better solution is at
hand.  In this case, there is; please try the patch below:

diff --git a/src/w32fns.c b/src/w32fns.c
index c32868f..b587677 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -10125,7 +10125,7 @@ to be converted to forward slashes by the caller.  */)
   CHECK_STRING (key);
   CHECK_STRING (name);
 
-  HKEY rootkey;
+  HKEY rootkey = HKEY_CURRENT_USER;
   if (EQ (root, QHKCR))
     rootkey = HKEY_CLASSES_ROOT;
   else if (EQ (root, QHKCU))
@@ -10139,10 +10139,7 @@ to be converted to forward slashes by the caller.  */)
   else if (!NILP (root))
     error ("unknown root key: %s", SDATA (SYMBOL_NAME (root)));
 
-  Lisp_Object val = w32_read_registry (NILP (root)
-				       ? HKEY_CURRENT_USER
-				       : rootkey,
-				       key, name);
+  Lisp_Object val = w32_read_registry (rootkey, key, name);
   if (NILP (val) && NILP (root))
     val = w32_read_registry (HKEY_LOCAL_MACHINE, key, name);
 



^ permalink raw reply related	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-17 19:45                                 ` Eli Zaretskii
@ 2018-08-17 21:33                                   ` Andy Moreton
  2018-08-18  6:25                                     ` Eli Zaretskii
  0 siblings, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-17 21:33 UTC (permalink / raw)
  To: emacs-devel

On Fri 17 Aug 2018, Eli Zaretskii wrote:

>> From: Andy Moreton <andrewjmoreton@gmail.com>
>> Date: Fri, 17 Aug 2018 16:21:24 +0100
>> 
>> >> C:/emacs/git/emacs/master/src/w32fns.c: In function 'Fw32_read_registry':
>> >> C:/emacs/git/emacs/master/src/w32fns.c:10142:21: warning: 'rootkey' may be used uninitialized in this function [-Wmaybe-uninitialized]
>> >>    Lisp_Object val = w32_read_registry (NILP (root)
>> >>                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> >>             ? HKEY_CURRENT_USER
>> >>             ~~~~~~~~~~~~~~~~~~~
>> >>             : rootkey,
>> >>             ~~~~~~~~~~
>> >>             key, name);
>> >>             ~~~~~~~~~~
>> >
>> > Thanks, pushed to the master branch.  I just made the new function's
>> > name a bit shorter.
>> 
>> Thanks. The warning shown above can be fixed with this patch:
>
> Thanks, but I prefer using UNINIT only where no better solution is at
> hand.  In this case, there is; please try the patch below:

Yes, your patch is a better fix (and fixes the warning).

Thanks,

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-17 21:33                                   ` Andy Moreton
@ 2018-08-18  6:25                                     ` Eli Zaretskii
  0 siblings, 0 replies; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-18  6:25 UTC (permalink / raw)
  To: Andy Moreton; +Cc: emacs-devel

> From: Andy Moreton <andrewjmoreton@gmail.com>
> Date: Fri, 17 Aug 2018 22:33:40 +0100
> 
> > Thanks, but I prefer using UNINIT only where no better solution is at
> > hand.  In this case, there is; please try the patch below:
> 
> Yes, your patch is a better fix (and fixes the warning).

Thanks, pushed.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-14 22:32                               ` Paul Eggert
  2018-08-17 14:33                                 ` Eli Zaretskii
@ 2018-08-18 16:09                                 ` Bruno Haible
  2018-08-18 17:19                                   ` Paul Eggert
  2018-08-18 18:41                                   ` Eli Zaretskii
  1 sibling, 2 replies; 60+ messages in thread
From: Bruno Haible @ 2018-08-18 16:09 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert, Andy Moreton, emacs-devel

> > There is also one function cast warning from gnulib code:
> > C:/emacs/git/emacs/master/lib/gettimeofday.c: In function 'initialize':
> > C:/emacs/git/emacs/master/lib/gettimeofday.c:48:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'void (*)(FILETIME *)' {aka 'void (*)(struct _FILETIME *)'} [-Wcast-function-type]
> >           (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");
> >           ^

The cast is there, because the results of GetProcAddress or dlsym
need to be cast to the proper function type before they can be
invoked. This code uses GetProcAddress so that it can exploit
features of newer Windows versions while at the same time still
work on older Windows versions.

The warning is there because you specified -Wcast-function-type.
You *wanted* to get informed about the cast. You got informed.

So, there are 4 options:
  1) Use static reference to Windows API functions.
  2) Use '#pragma GCC diagnostic ignored "-Wcast-function-type"'
  3) Remove -Wcast-function-type from the compiler options.
  4) Live with the warning.

I'm opposed to 1), since it removes either features or portability.

I could do 2), but it does not feel like the right thing, to silence
a compiler warning when the user has explicitly requested a warning.

So, please choose among 3) and 4).

Bruno




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 16:09                                 ` Bruno Haible
@ 2018-08-18 17:19                                   ` Paul Eggert
  2018-08-18 18:33                                     ` Bruno Haible
  2018-08-18 18:44                                     ` Eli Zaretskii
  2018-08-18 18:41                                   ` Eli Zaretskii
  1 sibling, 2 replies; 60+ messages in thread
From: Paul Eggert @ 2018-08-18 17:19 UTC (permalink / raw)
  To: Bruno Haible, bug-gnulib; +Cc: Andy Moreton, emacs-devel

Bruno Haible wrote:
> This code uses GetProcAddress so that it can exploit
> features of newer Windows versions while at the same time still
> work on older Windows versions.

Can this problem be addressed a bit better by using GetProcAddress only inside 
#ifndef HAVE_GETSYSTEMTIMEPRECISEASFILETIME code on builds for MS-Windows 7 and 
earlier, and directly using GetSystemTimePreciseAsFileTime on builds for 
MS-Windows 8 and later? That should fix the warning on builds for newer 
MS-Windows, which might be good enough.

>   3) Remove -Wcast-function-type from the compiler options.

If we do this in Emacs builds, it should be done only for MS-Windows since the 
warning is generally useful on other platforms.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 17:19                                   ` Paul Eggert
@ 2018-08-18 18:33                                     ` Bruno Haible
  2018-08-18 18:44                                     ` Eli Zaretskii
  1 sibling, 0 replies; 60+ messages in thread
From: Bruno Haible @ 2018-08-18 18:33 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Andy Moreton, bug-gnulib, emacs-devel

Paul Eggert wrote:
> Can this problem be addressed a bit better by using GetProcAddress only inside 
> #ifndef HAVE_GETSYSTEMTIMEPRECISEASFILETIME code on builds for MS-Windows 7 and 
> earlier, and directly using GetSystemTimePreciseAsFileTime on builds for 
> MS-Windows 8 and later?

I don't think the idea of having different builds for different versions of
the same operating system is going to fly.
  - The users can't manage it: Many users don't even know precisely what
    version of operating system they are running.
  - The developers don't want it: Why build and test 2 executables if they
    can achieve the same goal with half of the build and test effort?

Also, Emacs builds have pretty strong backward compatibility requirements.
I recall that Emacs still supported Windows 2000, when many other packages
listed Windows XP as the minimum. As currently ca. 35% of the Windows users
still use Windows 7 [1], you can imagine how many years it will take until
Emacs binaries don't need to run on Windows 7 any more.

Bruno

[1] https://windowsreport.com/windows-10-windows-7-popularity/




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 16:09                                 ` Bruno Haible
  2018-08-18 17:19                                   ` Paul Eggert
@ 2018-08-18 18:41                                   ` Eli Zaretskii
  2018-08-18 19:07                                     ` Andy Moreton
  2018-08-18 21:25                                     ` Bruno Haible
  1 sibling, 2 replies; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-18 18:41 UTC (permalink / raw)
  To: Bruno Haible; +Cc: andrewjmoreton, eggert, bug-gnulib, emacs-devel

> From: Bruno Haible <bruno@clisp.org>
> Date: Sat, 18 Aug 2018 18:09:27 +0200
> Cc: Paul Eggert <eggert@cs.ucla.edu>, Andy Moreton <andrewjmoreton@gmail.com>,
> 	emacs-devel@gnu.org
> 
> So, there are 4 options:
>   1) Use static reference to Windows API functions.
>   2) Use '#pragma GCC diagnostic ignored "-Wcast-function-type"'
>   3) Remove -Wcast-function-type from the compiler options.
>   4) Live with the warning.
> 
> I'm opposed to 1), since it removes either features or portability.
> 
> I could do 2), but it does not feel like the right thing, to silence
> a compiler warning when the user has explicitly requested a warning.
> 
> So, please choose among 3) and 4).

There's also this additional option:

  5) Cast through (void *).  Like this:

      GetSystemTimePreciseAsFileTimeFunc =
        (GetSystemTimePreciseAsFileTimeFuncType) (void (*) (void)) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 17:19                                   ` Paul Eggert
  2018-08-18 18:33                                     ` Bruno Haible
@ 2018-08-18 18:44                                     ` Eli Zaretskii
  2018-08-18 18:59                                       ` Paul Eggert
  1 sibling, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-18 18:44 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib, bruno, andrewjmoreton, emacs-devel

> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Sat, 18 Aug 2018 10:19:54 -0700
> Cc: Andy Moreton <andrewjmoreton@gmail.com>, emacs-devel@gnu.org
> 
> Bruno Haible wrote:
> > This code uses GetProcAddress so that it can exploit
> > features of newer Windows versions while at the same time still
> > work on older Windows versions.
> 
> Can this problem be addressed a bit better by using GetProcAddress only inside 
> #ifndef HAVE_GETSYSTEMTIMEPRECISEASFILETIME code on builds for MS-Windows 7 and 
> earlier, and directly using GetSystemTimePreciseAsFileTime on builds for 
> MS-Windows 8 and later? That should fix the warning on builds for newer 
> MS-Windows, which might be good enough.

Why not use the same method we used in the rest of Emacs instead of
jumping through all of those hoops?

And your suggestion will not work, because at build time it is not
known on what version of the OS will the code run.

> >   3) Remove -Wcast-function-type from the compiler options.
> 
> If we do this in Emacs builds, it should be done only for MS-Windows since the 
> warning is generally useful on other platforms.

There's no need to disable this warning at all.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 18:44                                     ` Eli Zaretskii
@ 2018-08-18 18:59                                       ` Paul Eggert
  2018-08-18 19:17                                         ` Eli Zaretskii
  0 siblings, 1 reply; 60+ messages in thread
From: Paul Eggert @ 2018-08-18 18:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: bug-gnulib, bruno, andrewjmoreton, emacs-devel

Eli Zaretskii wrote:
> There's no need to disable this warning at all.

I thought the problem was that people were using -Werror on MS-Windows and that 
builds were failing. If that's not the case, then we can simply go with Bruno's 
option (4), i.e., live with the warning.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 18:41                                   ` Eli Zaretskii
@ 2018-08-18 19:07                                     ` Andy Moreton
  2018-08-18 21:25                                     ` Bruno Haible
  1 sibling, 0 replies; 60+ messages in thread
From: Andy Moreton @ 2018-08-18 19:07 UTC (permalink / raw)
  To: emacs-devel; +Cc: bug-gnulib

On Sat 18 Aug 2018, Eli Zaretskii wrote:

>> From: Bruno Haible <bruno@clisp.org>
>> Date: Sat, 18 Aug 2018 18:09:27 +0200
>> Cc: Paul Eggert <eggert@cs.ucla.edu>, Andy Moreton <andrewjmoreton@gmail.com>,
>> 	emacs-devel@gnu.org
>> 
>> So, there are 4 options:
>>   1) Use static reference to Windows API functions.
>>   2) Use '#pragma GCC diagnostic ignored "-Wcast-function-type"'
>>   3) Remove -Wcast-function-type from the compiler options.
>>   4) Live with the warning.
>> 
>> I'm opposed to 1), since it removes either features or portability.
>> 
>> I could do 2), but it does not feel like the right thing, to silence
>> a compiler warning when the user has explicitly requested a warning.
>> 
>> So, please choose among 3) and 4).
>
> There's also this additional option:
>
>   5) Cast through (void *).  Like this:
>
>       GetSystemTimePreciseAsFileTimeFunc =
>         (GetSystemTimePreciseAsFileTimeFuncType) (void (*) (void)) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");

This is the sensible option. GetProcAddress returns FARPROC, so there is
no way of performing this cast correctly without some sort of type
mismatch.

The additional (void (*) (void)) cast deliberately suppresses the warning
in this case, which still allowing use of the warning to catch abuse of
function pointer types in other parts of the program.

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 18:59                                       ` Paul Eggert
@ 2018-08-18 19:17                                         ` Eli Zaretskii
  2018-08-18 19:57                                           ` Paul Eggert
  0 siblings, 1 reply; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-18 19:17 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib, bruno, andrewjmoreton, emacs-devel

> Cc: bruno@clisp.org, bug-gnulib@gnu.org, andrewjmoreton@gmail.com,
>  emacs-devel@gnu.org
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Sat, 18 Aug 2018 11:59:03 -0700
> 
> Eli Zaretskii wrote:
> > There's no need to disable this warning at all.
> 
> I thought the problem was that people were using -Werror on MS-Windows and that 
> builds were failing. If that's not the case, then we can simply go with Bruno's 
> option (4), i.e., live with the warning.

I urge you to reconsider and use the same technique we used in the
Emacs sources to shut up this warning.  There's no reason Gnulib
cannot use that technique.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 19:17                                         ` Eli Zaretskii
@ 2018-08-18 19:57                                           ` Paul Eggert
  0 siblings, 0 replies; 60+ messages in thread
From: Paul Eggert @ 2018-08-18 19:57 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: bug-gnulib, bruno, andrewjmoreton, emacs-devel

Eli Zaretskii wrote:
> I urge you to reconsider and use the same technique we used in the
> Emacs sources to shut up this warning.  There's no reason Gnulib
> cannot use that technique.

Is this the void (*) (void) cast that Andy just mentioned, or some other 
technique? Sorry, I've lost some context here.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 18:41                                   ` Eli Zaretskii
  2018-08-18 19:07                                     ` Andy Moreton
@ 2018-08-18 21:25                                     ` Bruno Haible
  2018-08-19  0:17                                       ` Bruno Haible
                                                         ` (2 more replies)
  1 sibling, 3 replies; 60+ messages in thread
From: Bruno Haible @ 2018-08-18 21:25 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: andrewjmoreton, eggert, bug-gnulib, emacs-devel

Eli Zaretskii wrote:
> There's also this additional option:
> 
>   5) Cast through (void *).  Like this:
> 
>       GetSystemTimePreciseAsFileTimeFunc =
>         (GetSystemTimePreciseAsFileTimeFuncType) (void (*) (void)) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");

Indeed, casting through (void *) or (void (*) (void)) avoids the
warning. I'm going to test this patch:


2018-08-18  Bruno Haible  <bruno@clisp.org>

	Avoid -Wcast-function-type warnings from casts after GetProcAddress.
	Reported by Andy Moreton <andrewjmoreton@gmail.com> in
	<https://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00468.html>.
	Solution proposed by Eli Zaretskii.
	* lib/getaddrinfo.c (GetProcAddress): Cast result to 'void *' first.
	* lib/gettimeofday.c (GetProcAddress): Likewise.
	* lib/link.c (GetProcAddress): Likewise.
	* lib/physmem.c (GetProcAddress): Likewise.
	* lib/poll.c (GetProcAddress): Likewise.
	* lib/select.c (GetProcAddress): Likewise.
	* lib/stat-w32.c (GetProcAddress): Likewise.

diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c
index 756c31b..7bf38e8 100644
--- a/lib/getaddrinfo.c
+++ b/lib/getaddrinfo.c
@@ -62,6 +62,11 @@
 #include "sockets.h"
 
 #ifdef WINDOWS_NATIVE
+
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
                                         const struct addrinfo*,
                                         struct addrinfo**);
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index bff40d7..36b5074 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -33,6 +33,10 @@
 
 #ifdef WINDOWS_NATIVE
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 /* GetSystemTimePreciseAsFileTime was introduced only in Windows 8.  */
 typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime);
 static GetSystemTimePreciseAsFileTimeFuncType GetSystemTimePreciseAsFileTimeFunc = NULL;
diff --git a/lib/link.c b/lib/link.c
index bf0b344..cff54a2 100644
--- a/lib/link.c
+++ b/lib/link.c
@@ -30,6 +30,10 @@
 #  define WIN32_LEAN_AND_MEAN
 #  include <windows.h>
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+#  define GetProcAddress \
+    (void *) GetProcAddress
+
 /* CreateHardLink was introduced only in Windows 2000.  */
 typedef BOOL (WINAPI * CreateHardLinkFuncType) (LPCTSTR lpFileName,
                                                 LPCTSTR lpExistingFileName,
diff --git a/lib/physmem.c b/lib/physmem.c
index cbb33ac..c89c0f0 100644
--- a/lib/physmem.c
+++ b/lib/physmem.c
@@ -59,8 +59,14 @@
 #endif
 
 #ifdef _WIN32
+
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
+
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 /*  MEMORYSTATUSEX is missing from older windows headers, so define
     a local replacement.  */
 typedef struct
@@ -76,6 +82,7 @@ typedef struct
   DWORDLONG ullAvailExtendedVirtual;
 } lMEMORYSTATUSEX;
 typedef WINBOOL (WINAPI *PFN_MS_EX) (lMEMORYSTATUSEX*);
+
 #endif
 
 #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
diff --git a/lib/poll.c b/lib/poll.c
index 26f7f12..576ec9f 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -84,6 +84,10 @@
    of SOCKETs, not bit masks of FDs.  */
 # undef select
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 static BOOL IsConsoleHandle (HANDLE h)
 {
   DWORD mode;
diff --git a/lib/select.c b/lib/select.c
index 3659cb5..ffb58ee 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -47,6 +47,10 @@
 
 #undef select
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+#define GetProcAddress \
+  (void *) GetProcAddress
+
 struct bitset {
   unsigned char in[FD_SETSIZE / CHAR_BIT];
   unsigned char out[FD_SETSIZE / CHAR_BIT];
diff --git a/lib/stat-w32.c b/lib/stat-w32.c
index 802b38a..c7a53f9 100644
--- a/lib/stat-w32.c
+++ b/lib/stat-w32.c
@@ -38,6 +38,10 @@
 #include "pathmax.h"
 #include "verify.h"
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+#define GetProcAddress \
+  (void *) GetProcAddress
+
 #if _GL_WINDOWS_STAT_INODES == 2
 /* GetFileInformationByHandleEx was introduced only in Windows Vista.  */
 typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile,




^ permalink raw reply related	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 21:25                                     ` Bruno Haible
@ 2018-08-19  0:17                                       ` Bruno Haible
  2018-08-19  2:44                                         ` Eli Zaretskii
  2018-08-19  7:08                                       ` Yuri Khan
  2018-08-20  3:01                                       ` Richard Stallman
  2 siblings, 1 reply; 60+ messages in thread
From: Bruno Haible @ 2018-08-19  0:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: andrewjmoreton, eggert, bug-gnulib, emacs-devel

> diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
> index bff40d7..36b5074 100644
> --- a/lib/gettimeofday.c
> +++ b/lib/gettimeofday.c
> @@ -33,6 +33,10 @@
>  
>  #ifdef WINDOWS_NATIVE
>  
> +/* Avoid warnings from gcc -Wcast-function-type.  */
> +# define GetProcAddress \
> +   (void *) GetProcAddress
> +
>  /* GetSystemTimePreciseAsFileTime was introduced only in Windows 8.  */
>  typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime);
>  static GetSystemTimePreciseAsFileTimeFuncType GetSystemTimePreciseAsFileTimeFunc = NULL;

Tested and pushed to gnulib.

Bruno




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-19  0:17                                       ` Bruno Haible
@ 2018-08-19  2:44                                         ` Eli Zaretskii
  0 siblings, 0 replies; 60+ messages in thread
From: Eli Zaretskii @ 2018-08-19  2:44 UTC (permalink / raw)
  To: Bruno Haible; +Cc: andrewjmoreton, eggert, bug-gnulib, emacs-devel

> From: Bruno Haible <bruno@clisp.org>
> Cc: bug-gnulib@gnu.org, eggert@cs.ucla.edu, andrewjmoreton@gmail.com, emacs-devel@gnu.org
> Date: Sun, 19 Aug 2018 02:17:52 +0200
> 
> > diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
> > index bff40d7..36b5074 100644
> > --- a/lib/gettimeofday.c
> > +++ b/lib/gettimeofday.c
> > @@ -33,6 +33,10 @@
> >  
> >  #ifdef WINDOWS_NATIVE
> >  
> > +/* Avoid warnings from gcc -Wcast-function-type.  */
> > +# define GetProcAddress \
> > +   (void *) GetProcAddress
> > +
> >  /* GetSystemTimePreciseAsFileTime was introduced only in Windows 8.  */
> >  typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime);
> >  static GetSystemTimePreciseAsFileTimeFuncType GetSystemTimePreciseAsFileTimeFunc = NULL;
> 
> Tested and pushed to gnulib.

Thank you.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 21:25                                     ` Bruno Haible
  2018-08-19  0:17                                       ` Bruno Haible
@ 2018-08-19  7:08                                       ` Yuri Khan
  2018-08-19  8:40                                         ` Bruno Haible
  2018-08-20  3:01                                       ` Richard Stallman
  2 siblings, 1 reply; 60+ messages in thread
From: Yuri Khan @ 2018-08-19  7:08 UTC (permalink / raw)
  To: bruno
  Cc: bug-gnulib, Eli Zaretskii, Paul Eggert, andrewjmoreton,
	Emacs developers

On Sun, Aug 19, 2018 at 4:26 AM Bruno Haible <bruno@clisp.org> wrote:

> Indeed, casting through (void *) or (void (*) (void)) avoids the
> warning.

I seem to remember C does not guarantee that pointers to functions
must survive casting through void*. It does for casting between
function pointer types. So casting through (void (*)(void)) is going
to be more portable.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-19  7:08                                       ` Yuri Khan
@ 2018-08-19  8:40                                         ` Bruno Haible
  0 siblings, 0 replies; 60+ messages in thread
From: Bruno Haible @ 2018-08-19  8:40 UTC (permalink / raw)
  To: Yuri Khan
  Cc: bug-gnulib, Eli Zaretskii, Paul Eggert, andrewjmoreton,
	Emacs developers

Yuri Khan wrote:
> > Indeed, casting through (void *) or (void (*) (void)) avoids the
> > warning.
> 
> I seem to remember C does not guarantee that pointers to functions
> must survive casting through void*.

Yes, on some old architectures like Windows 3.1 a function pointer and
a 'void *' had different representations. But the fact that 'dlsym' has
a 'void *' return value proves that this is not an issue nowadays any more.

> It does for casting between
> function pointer types. So casting through (void (*)(void)) is going
> to be more portable.

No. GCC sometimes generates a __builtin_trap (a kind of undebuggable
abort()) when you cast function pointers in an incompatible way. (*) So,
I would avoid this.

Bruno

(*) The precise conditions I know of are: 1. take the address of a declared
    function, 2. cast it to an incompatible function type, 3. invoke it
    with arguments according to this function type. But maybe there are
    other situations where the same thing occurs or might occur in the future?
    Who knows...




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-18 21:25                                     ` Bruno Haible
  2018-08-19  0:17                                       ` Bruno Haible
  2018-08-19  7:08                                       ` Yuri Khan
@ 2018-08-20  3:01                                       ` Richard Stallman
  2018-08-20  8:20                                         ` Andy Moreton
  2 siblings, 1 reply; 60+ messages in thread
From: Richard Stallman @ 2018-08-20  3:01 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib, eliz, eggert, andrewjmoreton, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

	  > Avoid -Wcast-function-type warnings from casts after GetProcAddress.
	  > Reported by Andy Moreton <andrewjmoreton@gmail.com> in
	  > <https://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00468.html>.
	  > Solution proposed by Eli Zaretskii.

Why make our code more complicated to cater to a program?

-- 
Dr Richard Stallman
President, Free Software Foundation (https://gnu.org, https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-20  3:01                                       ` Richard Stallman
@ 2018-08-20  8:20                                         ` Andy Moreton
  2018-08-21  3:37                                           ` Richard Stallman
  0 siblings, 1 reply; 60+ messages in thread
From: Andy Moreton @ 2018-08-20  8:20 UTC (permalink / raw)
  To: emacs-devel; +Cc: bug-gnulib

On Sun 19 Aug 2018, Richard Stallman wrote:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> 	  > Avoid -Wcast-function-type warnings from casts after GetProcAddress.
> 	  > Reported by Andy Moreton <andrewjmoreton@gmail.com> in
> 	  > <https://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00468.html>.
> 	  > Solution proposed by Eli Zaretskii.
>
> Why make our code more complicated to cater to a program?

GetProcAddress is used for runtime linking on Windows (similar to dlsym
on POSIX platforms). It returns a FARPROC function pointer type, which
has a different function signature to almost any function that you care
to lookup for runtime linking.

GCC 8.1 and later have a new -Wcast-function-type warning (which is
useful, and which emacs enables). This warning requires either an
additional cast or a pragma to suppress the warning at these call sites,
as the mismatch of function signature cannot be fixed otherwise.

Doing so allow emacs to continue to use the warning, and thus warn about
misuse of function pointers at other places in emacs.

    AndyM




^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-20  8:20                                         ` Andy Moreton
@ 2018-08-21  3:37                                           ` Richard Stallman
  2018-08-21  3:43                                             ` Paul Eggert
  0 siblings, 1 reply; 60+ messages in thread
From: Richard Stallman @ 2018-08-21  3:37 UTC (permalink / raw)
  To: Andy Moreton; +Cc: bug-gnulib, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > GCC 8.1 and later have a new -Wcast-function-type warning (which is
  > useful, and which emacs enables). This warning requires either an
  > additional cast or a pragma to suppress the warning at these call sites,
  > as the mismatch of function signature cannot be fixed otherwise.

How many useful warnings has that option given us?

-- 
Dr Richard Stallman
President, Free Software Foundation (https://gnu.org, https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-21  3:37                                           ` Richard Stallman
@ 2018-08-21  3:43                                             ` Paul Eggert
  2018-08-22  4:03                                               ` Richard Stallman
  0 siblings, 1 reply; 60+ messages in thread
From: Paul Eggert @ 2018-08-21  3:43 UTC (permalink / raw)
  To: rms, Andy Moreton; +Cc: bug-gnulib, emacs-devel

Richard Stallman wrote:
> How many useful warnings has that option given us?

It's given me useful warnings on several occasions while developing. I did not 
count how many.



^ permalink raw reply	[flat|nested] 60+ messages in thread

* Re: New warnings on emacs-26 branch with gcc 8.2.0
  2018-08-21  3:43                                             ` Paul Eggert
@ 2018-08-22  4:03                                               ` Richard Stallman
  0 siblings, 0 replies; 60+ messages in thread
From: Richard Stallman @ 2018-08-22  4:03 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib, andrewjmoreton, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > It's given me useful warnings on several occasions while developing. I did not 
  > count how many.

Interesting.  Anyone else find it useful?

-- 
Dr Richard Stallman
President, Free Software Foundation (https://gnu.org, https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2018-08-22  4:03 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-05 16:33 New warnings on emacs-26 branch with gcc 8.2.0 Andy Moreton
2018-08-05 16:41 ` Noam Postavsky
2018-08-05 19:56 ` Paul Eggert
2018-08-05 22:23   ` Andy Moreton
2018-08-05 22:47     ` Paul Eggert
2018-08-06  8:30       ` Andy Moreton
2018-08-06 15:16         ` Eli Zaretskii
2018-08-06 15:26           ` Andy Moreton
2018-08-06 15:34             ` Eli Zaretskii
2018-08-06 18:37         ` Paul Eggert
2018-08-06 21:36           ` Andy Moreton
2018-08-06 21:58             ` Paul Eggert
2018-08-11 15:06               ` Andy Moreton
2018-08-11 19:23                 ` Paul Eggert
2018-08-11 19:38                   ` Andy Moreton
2018-08-11 20:13                     ` Paul Eggert
2018-08-06  2:26   ` Eli Zaretskii
2018-08-06  3:16     ` Paul Eggert
2018-08-11  8:40       ` Eli Zaretskii
2018-08-11 10:41         ` Andy Moreton
2018-08-11 10:51           ` Eli Zaretskii
2018-08-11 15:02             ` Andy Moreton
2018-08-11 17:15               ` Eli Zaretskii
2018-08-11 18:13                 ` Andy Moreton
2018-08-11 18:26                   ` Eli Zaretskii
2018-08-11 18:36                     ` Andy Moreton
2018-08-11 19:04                       ` Andy Moreton
2018-08-11 19:10                         ` Eli Zaretskii
2018-08-14 12:59                           ` Andy Moreton
2018-08-14 21:20                             ` Andy Moreton
2018-08-14 22:32                               ` Paul Eggert
2018-08-17 14:33                                 ` Eli Zaretskii
2018-08-18 16:09                                 ` Bruno Haible
2018-08-18 17:19                                   ` Paul Eggert
2018-08-18 18:33                                     ` Bruno Haible
2018-08-18 18:44                                     ` Eli Zaretskii
2018-08-18 18:59                                       ` Paul Eggert
2018-08-18 19:17                                         ` Eli Zaretskii
2018-08-18 19:57                                           ` Paul Eggert
2018-08-18 18:41                                   ` Eli Zaretskii
2018-08-18 19:07                                     ` Andy Moreton
2018-08-18 21:25                                     ` Bruno Haible
2018-08-19  0:17                                       ` Bruno Haible
2018-08-19  2:44                                         ` Eli Zaretskii
2018-08-19  7:08                                       ` Yuri Khan
2018-08-19  8:40                                         ` Bruno Haible
2018-08-20  3:01                                       ` Richard Stallman
2018-08-20  8:20                                         ` Andy Moreton
2018-08-21  3:37                                           ` Richard Stallman
2018-08-21  3:43                                             ` Paul Eggert
2018-08-22  4:03                                               ` Richard Stallman
2018-08-17 14:32                             ` Eli Zaretskii
2018-08-17 15:21                               ` Andy Moreton
2018-08-17 19:45                                 ` Eli Zaretskii
2018-08-17 21:33                                   ` Andy Moreton
2018-08-18  6:25                                     ` Eli Zaretskii
2018-08-11 19:18                       ` Paul Eggert
2018-08-15 15:53                         ` Andy Moreton
2018-08-16 21:05                           ` Paul Eggert
2018-08-17 14:34                           ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).