[Mesa-dev] [PATCH] i965: quieten compiler warning about out-of-bounds access

Jason Ekstrand jason at jlekstrand.net
Tue Jan 5 17:30:53 PST 2016


On Jan 4, 2016 8:30 PM, "Ilia Mirkin" <imirkin at alum.mit.edu> wrote:
>
> gcc 4.9.3 shows the following error:
>
> brw_vue_map.c:260:20: warning: array subscript is above array bounds
> [-Warray-bounds]
>     return brw_names[slot - VARYING_SLOT_MAX];
>
> This is because BRW_VARYING_SLOT_COUNT is a valid value for the enum
> type. Adding an assert will generate no additional code but will teach
> the compiler to not complain.

What of you build in release mode?

> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>  src/mesa/drivers/dri/i965/brw_vue_map.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vue_map.c
b/src/mesa/drivers/dri/i965/brw_vue_map.c
> index 09eadbc..fea2436 100644
> --- a/src/mesa/drivers/dri/i965/brw_vue_map.c
> +++ b/src/mesa/drivers/dri/i965/brw_vue_map.c
> @@ -257,6 +257,7 @@ varying_name(brw_varying_slot slot)
>        [BRW_VARYING_SLOT_PNTC - VARYING_SLOT_MAX] =
"BRW_VARYING_SLOT_PNTC",
>     };
>
> +   assert(slot < BRW_VARYING_SLOT_COUNT);
>     return brw_names[slot - VARYING_SLOT_MAX];
>  }
>
> --
> 2.4.10
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20160105/fe28330c/attachment.html>


More information about the mesa-dev mailing list