[Mesa-dev] [PATCH 09/17] spirv: Silence compiler warning about undefined srcs[0]

Ian Romanick idr at freedesktop.org
Mon Feb 12 21:52:23 UTC 2018


On 02/10/2018 08:33 AM, Eric Anholt wrote:
> It doesn't know that elems >= 1.

Does adding assume(elems >= 1) help?

> Cc: Jason Ekstrand <jason.ekstrand at intel.com>
> ---
>  src/compiler/spirv/spirv_to_nir.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
> index c6df764682ec..f86d45511df8 100644
> --- a/src/compiler/spirv/spirv_to_nir.c
> +++ b/src/compiler/spirv/spirv_to_nir.c
> @@ -2923,7 +2923,7 @@ vtn_handle_composite(struct vtn_builder *b, SpvOp opcode,
>     case SpvOpCompositeConstruct: {
>        unsigned elems = count - 3;
>        if (glsl_type_is_vector_or_scalar(type)) {
> -         nir_ssa_def *srcs[4];
> +         nir_ssa_def *srcs[4] = { NULL };
>           for (unsigned i = 0; i < elems; i++)
>              srcs[i] = vtn_ssa_value(b, w[3 + i])->def;
>           val->ssa->def =
> 



More information about the mesa-dev mailing list