From: Andy Moreton <andrewjmoreton@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: New warnings on emacs-26 branch with gcc 8.2.0
Date: Sat, 11 Aug 2018 19:13:00 +0100 [thread overview]
Message-ID: <86in4gixg3.fsf@gmail.com> (raw)
In-Reply-To: 83mutslt8f.fsf@gnu.org
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
next prev parent reply other threads:[~2018-08-11 18:13 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86in4gixg3.fsf@gmail.com \
--to=andrewjmoreton@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.