[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] GLPK on 64 bit Linux
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] GLPK on 64 bit Linux |
Date: |
Thu, 25 Mar 2010 17:58:54 +0300 |
> My understanding is that sizeof() is 64 bits under a 64-bit OS and
> 32 bits under a 32-bit OS. If sizeof() would be assigned to an int
> variable, I do now know exactly how the conversion from 64 bits to 32
> bits will be handled.
64-bit unsigned int is converted to 32-bit signed int by simple
dropping its high 32 bits.
> xcalloc is defined as void * glp_calloc(int, int). GLPK puts
> sizeof() as the second argument to xcalloc in many codes.
In glpk there are no structs longer than 256 bytes, so no overflow may
happen due to such conversions.
> I do not know how unsigned int is converted to unsigned short in a 64
> bit OS.
> I had generated glpk in Debug mode. It stopped during the
> conversion because the unsigned int is longer than unsigned short at a
> few places.
I guess you mean the following run-time error:
Run-Time Check Failure #1 - A cast to a smaller data type has
caused a loss of data. If this was intentional, you should mask
the source of the cast with the appropriate bitmask. For
example:
char c = (i & 0xFF);
To avoid this error you need to turn off the cast to smaller type
check in the project settings. It is a MSVC quirk. Such conversions
are valid and allowed by the ISO C Standard.