[FFmpeg-devel] llvm failure : don't do undefined shift

matthieu castet castet.matthieu
Thu Aug 20 19:52:25 CEST 2009


Hi,

the put_bits can be called with
	unsigned int bit_buf = 0;
	int bit_left = 32;
	int n = 32;
	unsigned int value = 0x1ba;

in the case of ALT_BITSTREAM_WRITER and BITSTREAM_WRITER_LE is not defined, we
will do "bit_buf<<=bit_left;"
But sizeof(bit_buf) == 32 and bit_left==32, and we are in a undefined 
behavior[1].

I don't know how to fix this, I only found strange that we have "if (n <
bit_left) {" instead of "if (n <= bit_left) {"


Matthieu


[1] C99 standard, ?6.5.7
If the value of the right operand is negative or is
greater than or equal to the width of the promoted 
left operand, the behavior is undefined.





More information about the ffmpeg-devel mailing list