[XviD-devel] gmc weirdo

Christoph Lampert chl at math.uni-bonn.de
Sun Aug 10 16:35:47 CEST 2003


On Sun, 10 Aug 2003, Radek Czyz wrote:

> Thank you Christoph. I replaced the code.
> 
> As far as I can tell the trick should work. Unfortunately, VS
> optimizer figured out that the third case cannot happen and removed
> it - the second case was being executed instead. What a stupid
> compiler.

Hi,

it seems that you spotted a bug in MSVC++ compiler. According to the
standard, converting negative values of (int) to (unsigned int)
is supposed to be done as: 

[...] the value is converted by repeatedly adding or subtracting one
more than the maximum value that can be represented in the new type
until the value is in the range of the new type. 

Which on machines with 2's complement for negative number (and I don't
think any other are still available) is just the same as interpreting the 
"signed" bitpattern as "unsigned". In any way, every negative number
becomes larger than any positive number, so the check does exactly
what it's supposed to do. 

Anyway, the code is correct, but that doesn't help the users, does it?
We'll need a workaroud for VC++. 

gruel




More information about the XviD-devel mailing list