Date: Wed, 25 Nov 1998 10:21:07 -0500 Message-Id: <199811251521.KAA26697@envy.delorie.com> From: DJ Delorie To: djgpp AT delorie DOT com In-reply-to: Subject: Re: (Probably not but...) a flaw in DJGPP? References: Reply-To: djgpp AT delorie DOT com > inline fixed &operator= (int a) {value = long(a)<<16;return *this;} > > As copied for the class's documentation: > > "In general, there are four functions for each operation , one each for > fixed,int, float and double. Thankfully, Watcom will automatically cast > any other ordinal types (short, long, char, unsigned int, etc.) to int." > > I was very disapointed to see that DJGPP does not have that quality! > A simple test program compiles fine when using ints, but gives me errors for > unknown combination of operands if I use unsigned longs. Unsigned longs can't cast to ints, because they may represent values that aren't representable in an int. You can cast signed or unsigned shorts or chars, or signed ints, but not unsigned ints or any longs (yes, I know sizeof(long) == sizeof(int) in djgpp, but you can't guarantee that, so you shouldn't do it). If Watcom is silently truncating your numbers and doing an automatic conversion that may corrupt your data, it has a bug.