Bug 39063 - libgcc2.c:mprotect() for mingw, incompatible pointer type warning
Summary: libgcc2.c:mprotect() for mingw, incompatible pointer type warning
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.0
: P3 trivial
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-01 16:52 UTC by Ozkan Sezer
Modified: 2009-04-13 11:55 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-pc-mingw32
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-02-21 09:52:19


Attachments
mprotect warnings fix (505 bytes, patch)
2009-02-01 16:53 UTC, Ozkan Sezer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ozkan Sezer 2009-02-01 16:52:49 UTC
in windows replacement of mprotect() in libgcc2.c uses VirtualProtect
which requires an unsigned, not a signed ptr as its last argument. the
attached patch fixes a 'may be used uninitialized' warning, too.
here are the warnings:
../../../gcc-svn/libgcc/../gcc/libgcc2.c: In function 'mprotect':
../../../gcc-svn/libgcc/../gcc/libgcc2.c:2079: warning: passing argument 4 of 'VirtualProtect' from incompatible pointer type
/opt/buildroot/gcc-svn/winsup/mingw/include/winbase.h:1126: note: expected 'PDWORD' but argument is of type 'int *'
../../../gcc-svn/libgcc/../gcc/libgcc2.c:2064: warning: 'np' may be used uninitialized in this function
Comment 1 Ozkan Sezer 2009-02-01 16:53:18 UTC
Created attachment 17222 [details]
mprotect warnings fix
Comment 3 gerald@gcc.gnu.org 2009-03-19 10:40:47 UTC
Subject: Bug 39063

Author: gerald
Date: Thu Mar 19 10:40:32 2009
New Revision: 144957

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144957
Log:
	PR target/39063
	* libgcc2.c (mprotect): Do not use signed arguments for
	VirtualProtect, use DWORD arguments.  Also fix the 'may
	be used uninitialized' warning for the np variable.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/libgcc2.c

Comment 4 H.J. Lu 2009-03-19 14:52:33 UTC
The fix may have broken cross compiling:

http://gcc.gnu.org/ml/gcc/2009-03/msg00525.html
Comment 5 Ozkan Sezer 2009-03-19 17:49:52 UTC
The prototype for VirtualProtect() is known but the definition of DWORD is not??
Hrmph. In any case, it should be fixed easily by changing DWORD into unsigned int
which is what a DWORD is always defined as.
Comment 6 Ozkan Sezer 2009-04-13 11:55:34 UTC
(In reply to comment #4)
> The fix may have broken cross compiling:
> 
> http://gcc.gnu.org/ml/gcc/2009-03/msg00525.html
> 

PR39503 has already been closed for some fime, so this one should be closed, too.