[Piglit] [PATCH] ext_transform_feedback-alignment: Fix undefined multiplication.

Ian Romanick idr at freedesktop.org
Wed Feb 19 19:54:51 PST 2014


On 02/19/2014 01:25 AM, Vinson Lee wrote:
> This patch fixes this GCC aggressive-loop-optimizations warning.
> 
> alignment.c: In function 'piglit_display':
> alignment.c:184:28: warning: iteration 32u invokes undefined behavior [-Waggressive-loop-optimizations]
>     0x00010203 + 0x04040404 * i;
>                             ^

Because signed overflow is undefined?  Maybe the literals should also
get decorated with u.  Even after all these years, the weirdness in C
never fails to amaze me...

With or without u added to the literals,

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> alignment.c:182:2: note: containing loop
>   for (i = 0; i < EXPECTED_NUM_OUTPUTS; ++i) {
>   ^
> 
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
>  tests/spec/ext_transform_feedback/alignment.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/spec/ext_transform_feedback/alignment.c b/tests/spec/ext_transform_feedback/alignment.c
> index dda8823..5014066 100644
> --- a/tests/spec/ext_transform_feedback/alignment.c
> +++ b/tests/spec/ext_transform_feedback/alignment.c
> @@ -151,7 +151,7 @@ enum piglit_result piglit_display(void)
>  	GLuint *readback;
>  	GLuint buffer[BUFFER_SIZE];
>  	GLuint expected[BUFFER_SIZE];
> -	int i;
> +	unsigned int i;
>  	GLboolean pass = GL_TRUE;
>  
>  	glUseProgram(prog);
> 



More information about the Piglit mailing list