public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/108662] New: Cast between incompatible function types in libiberty/physmem.c under MinGW-W64/MSYS2 on Windows 10
@ 2023-02-03 20:15 jdx at o2 dot pl
  2023-02-05 23:08 ` [Bug other/108662] " jdx at o2 dot pl
  0 siblings, 1 reply; 2+ messages in thread
From: jdx at o2 dot pl @ 2023-02-03 20:15 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug other/108662] Cast between incompatible function types in libiberty/physmem.c under MinGW-W64/MSYS2 on Windows 10
  2023-02-03 20:15 [Bug other/108662] New: Cast between incompatible function types in libiberty/physmem.c under MinGW-W64/MSYS2 on Windows 10 jdx at o2 dot pl
@ 2023-02-05 23:08 ` jdx at o2 dot pl
  0 siblings, 0 replies; 2+ messages in thread
From: jdx at o2 dot pl @ 2023-02-05 23:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jan Dubiec <jdx at o2 dot pl> ---
Created attachment 54410
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54410&action=edit
Proposed patch

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-05 23:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 20:15 [Bug other/108662] New: Cast between incompatible function types in libiberty/physmem.c under MinGW-W64/MSYS2 on Windows 10 jdx at o2 dot pl
2023-02-05 23:08 ` [Bug other/108662] " jdx at o2 dot pl

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).