public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jdx at o2 dot pl" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug other/108662] New: Cast between incompatible function types in libiberty/physmem.c under MinGW-W64/MSYS2 on Windows 10
Date: Fri, 03 Feb 2023 20:15:49 +0000	[thread overview]
Message-ID: <bug-108662-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108662

            Bug ID: 108662
           Summary: Cast between incompatible function types in
                    libiberty/physmem.c under MinGW-W64/MSYS2 on Windows
                    10
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: internal-improvement
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jdx at o2 dot pl
  Target Milestone: ---
              Host: x86_64-w64-mingw32
             Build: x86_64-w64-mingw32

The following warning appears when gcc is build under MinGW-W64/MSYS2:

gcc -c -DHAVE_CONFIG_H -g -O2      -I. -I../../../gcc/libiberty/../include  -W
-Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic
 -D_GNU_SOURCE  ../../../gcc/libiberty/physmem.c -o physmem.o
../../../gcc/libiberty/physmem.c: In function 'physmem_total':
../../../gcc/libiberty/physmem.c:161:18: warning: cast between incompatible
function types from 'FARPROC' {aka 'long long int (*)()'} to 'WINBOOL
(*)(lMEMORYSTATUSEX *)' {aka 'int (*)(lMEMORYSTATUSEX *)'}
[-Wcast-function-type]
  161 |     if ((pfnex = (PFN_MS_EX) GetProcAddress (h,
"GlobalMemoryStatusEx")))
      |                  ^
../../../gcc/libiberty/physmem.c: In function 'physmem_available':
../../../gcc/libiberty/physmem.c:262:18: warning: cast between incompatible
function types from 'FARPROC' {aka 'long long int (*)()'} to 'WINBOOL
(*)(lMEMORYSTATUSEX *)' {aka 'int (*)(lMEMORYSTATUSEX *)'}
[-Wcast-function-type]
  262 |     if ((pfnex = (PFN_MS_EX) GetProcAddress (h,
"GlobalMemoryStatusEx")))
      |                  ^


The offending code was added in 2003
(https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ed935c35314a6fe3b0c699bf642c704655873d49)
and has survived virtually without changes until this day. Perhaps 20 years
later it is time to clean the code – remove definitions of lMEMORYSTATUSEX and
PFN_MS_EX at the top, remove calls to GlobalMemoryStatus (which is pretty much
useless these days) and call GlobalMemoryStatusEx directly.

             reply	other threads:[~2023-02-03 20:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 20:15 jdx at o2 dot pl [this message]
2023-02-05 23:08 ` [Bug other/108662] " jdx at o2 dot pl

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=bug-108662-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.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.
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).