[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New warnings on emacs-26 branch with gcc 8.2.0
From: |
Andy Moreton |
Subject: |
Re: New warnings on emacs-26 branch with gcc 8.2.0 |
Date: |
Sat, 11 Aug 2018 19:13:00 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt) |
On Sat 11 Aug 2018, Eli Zaretskii wrote:
>> From: Andy Moreton <address@hidden>
>> Date: Sat, 11 Aug 2018 16:02:03 +0100
>>
>> On Sat 11 Aug 2018, Eli Zaretskii wrote:
>>
>> >> From: Andy Moreton <address@hidden>
>> >> 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
- Re: New warnings on emacs-26 branch with gcc 8.2.0, (continued)
Re: New warnings on emacs-26 branch with gcc 8.2.0, Eli Zaretskii, 2018/08/05
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Paul Eggert, 2018/08/05
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Eli Zaretskii, 2018/08/11
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Andy Moreton, 2018/08/11
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Eli Zaretskii, 2018/08/11
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Andy Moreton, 2018/08/11
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Eli Zaretskii, 2018/08/11
- Re: New warnings on emacs-26 branch with gcc 8.2.0,
Andy Moreton <=
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Eli Zaretskii, 2018/08/11
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Andy Moreton, 2018/08/11
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Andy Moreton, 2018/08/11
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Eli Zaretskii, 2018/08/11
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Andy Moreton, 2018/08/14
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Andy Moreton, 2018/08/14
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Paul Eggert, 2018/08/14
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Eli Zaretskii, 2018/08/17
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Bruno Haible, 2018/08/18
- Re: New warnings on emacs-26 branch with gcc 8.2.0, Paul Eggert, 2018/08/18