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.