These codes are replaced with unsigned short c = (unsigned short)( i & USHRT_MAX);
The modified codes can produce 13.75 for vpm2.mps of MIPLIB 2003. Thanks. -----Original Message----- From: Michael Hennebry [mailto:henne...@web.cs.ndsu.nodak.edu] Sent: Tuesday, January 05, 2010 10:44 AM To: Andrew Makhorin Cc: Cheng,Jen-Min; help-glpk@gnu.org Subject: Re: FW: [Help-glpk] bigmul in glblib05.c On Tue, 5 Jan 2010, Andrew Makhorin wrote: >> 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); What this does is implementation dependent. char c = (char)i; char c = (char)(i & 0xFF); char c = (char)(i & CHAR_MAX); char c = (char)(i & UCHAR_MAX); char c = (char)(unsigned char)i; would all be better, but all still implementation dependent. None should give you a warning. They might give you five different results. If chars are unsigned, all except possibly the second will do what you probably want. Life is more interesting if chars are signed. C defines conversions from unsigned to signed types only in their common range. The others are implemenation defined. > This advice is helpful for quiche eaters only :) > >> Because MSVS 2008 would issue warning for such a conversion, the bigmul >> is modified as > >> union { >> unsigned int uint; >> struct { unsigned short ush1, ush2 ;} ush; >> } tuiush; >> [...] >> x[i+j] = (unsigned short)tuiush.ush.ush1; If preceded by an assignment to tuish.uint, it would be undefined behaviour. -- Michael henne...@web.cs.ndsu.nodak.edu "Pessimist: The glass is half empty. Optimist: The glass is half full. Engineer: The glass is twice as big as it needs to be." _______________________________________________ Help-glpk mailing list Help-glpk@gnu.org http://lists.gnu.org/mailman/listinfo/help-glpk