From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.devel,gmane.comp.lib.gnulib.bugs Subject: Re: New warnings on emacs-26 branch with gcc 8.2.0 Date: Sat, 18 Aug 2018 20:07:20 +0100 Message-ID: <86o9dzjxxz.fsf@gmail.com> References: <86a7q0ai2z.fsf@gmail.com> <86y3d88x1u.fsf@gmail.com> <9ab72594-da61-a3f4-cac4-6e61cda67da3@cs.ucla.edu> <4195986.6xTypejAr3@omega> <83d0uffrft.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1534619247 4415 195.159.176.226 (18 Aug 2018 19:07:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Aug 2018 19:07:27 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt) Cc: bug-gnulib@gnu.org To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 18 21:07:23 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fr6ZF-00010f-5T for ged-emacs-devel@m.gmane.org; Sat, 18 Aug 2018 21:07:21 +0200 Original-Received: from localhost ([::1]:40157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fr6bL-00037p-As for ged-emacs-devel@m.gmane.org; Sat, 18 Aug 2018 15:09:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fr6ZW-0001n1-Jh for emacs-devel@gnu.org; Sat, 18 Aug 2018 15:07:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fr6ZS-0002sQ-Fr for emacs-devel@gnu.org; Sat, 18 Aug 2018 15:07:38 -0400 Original-Received: from [195.159.176.226] (port=40892 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fr6ZS-0002rc-9C for emacs-devel@gnu.org; Sat, 18 Aug 2018 15:07:34 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fr6XJ-0007AZ-31 for emacs-devel@gnu.org; Sat, 18 Aug 2018 21:05:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 36 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:4wi7qWNtrz+OUDnDCt2OthjlE8k= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228666 gmane.comp.lib.gnulib.bugs:39214 Archived-At: On Sat 18 Aug 2018, Eli Zaretskii wrote: >> From: Bruno Haible >> Date: Sat, 18 Aug 2018 18:09:27 +0200 >> Cc: Paul Eggert , Andy Moreton , >> 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