Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

jacob: lcc64 compiler -1 vs DWORD_PTR compare problem

76 views
Skip to first unread message

johnco...@gmail.com

unread,
May 17, 2013, 7:33:51 AM5/17/13
to
compiled with lcc64

int main()
{
int r = -1;
DWORD_PTR zero = 0;

if (r > zero) printf("r > 0\n");
}

it will print 'r>0'

i'm not sure is this compiler bug or not, but it makes a lot of problems with win32--->win64 code migration.

-1 is used in SOCKET_ERROR and INVALID_HANDLE_VALUE

workaround:

if (r>(int)zero) will work ok.

jacob navia

unread,
May 17, 2013, 10:44:51 AM5/17/13
to
Le 17/05/13 13:33, johnco...@gmail.com a �crit :
DWORD is an <unsigned> int.
R will be converted to unsigned, i.e. to 0xffffffff, that is 4294967295.

Since 4294967295 is bigger than zero, the result is what you get.

Please remember

Comparisons between signed/unsigned types are risky.

Jeb

unread,
Jun 9, 2013, 5:36:55 AM6/9/13
to
jacob navia wrote:
[idiocy]

You are an idiot. :P



0 new messages