This is a classic situation (example taken from Michel Xhaards jpegenc library):
Look at line 6 of this code snippet. It throws a warning like this:Code:for (i = rows; i > 0; i--) { for (j = cols; j > 0; j--) *Y1_Ptr++ = *input_ptr++ - 128; for (j = 8 - cols; j > 0; j--) *Y1_Ptr++ = *(Y1_Ptr - 1); input_ptr += incr; }
The warning is justified because things can go wrong. It is entirely up to the compiler what the value of Y1_Ptr would be in the right part of the line. It is undefined according to the standard. Only the original coder knows what the code should do in his opinion.Code:encoder.c:392: warning: operation on 'Y1_Ptr' may be undefined
Code like this can not be packaged. I have to patch it. Would you think that this fix meets the original intentions:
Any comments would be helpful.Code:*Y1_Ptr = *(Y1_Ptr - 1); Y1_Ptr++;



Reply With Quote



Bookmarks