[Piglit] [PATCH] textureGather: Avoid variable length arrays.

Ilia Mirkin imirkin at alum.mit.edu
Mon Apr 28 07:57:31 PDT 2014


On Mon, Apr 28, 2014 at 10:12 AM,  <jfonseca at vmware.com> wrote:
> From: José Fonseca <jfonseca at vmware.com>
>
> Not supported by MSVC.

Sorry, that was my bad. Is there any way to get gcc to refuse the same
(or at least similar) things to MSVC? Perhaps -std=c89 or something? I
hate to cause build breaks for others, but it's hard to avoid when
using different build tools. If some options for gcc get added to make
it more like MSVC in terms of the language it accepts, these types of
errors would hopefully become less frequent.

  -ilia

> ---
>  tests/texturing/shaders/textureGather.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/tests/texturing/shaders/textureGather.c b/tests/texturing/shaders/textureGather.c
> index cb7fef0..bd48790 100644
> --- a/tests/texturing/shaders/textureGather.c
> +++ b/tests/texturing/shaders/textureGather.c
> @@ -201,7 +201,9 @@ static void
>  upload_verts(void)
>  {
>         if (stage == VS) {
> -               float v[4 * texture_width * texture_height], *pv = v;
> +               size_t size = 4 * texture_width * texture_height * sizeof(float);
> +               float *v = (float *)malloc(size);
> +               float *pv = v;
>                 int i, j;
>                 for (j = 0; j < texture_height; j++)
>                         for (i = 0; i < texture_width; i++) {
> @@ -210,7 +212,8 @@ upload_verts(void)
>                                 *pv++ = 0;
>                                 *pv++ = 1;
>                         }
> -               glBufferData(GL_ARRAY_BUFFER, sizeof(v), v, GL_STATIC_DRAW);
> +               glBufferData(GL_ARRAY_BUFFER, size, v, GL_STATIC_DRAW);
> +               free(v);
>         }
>         else {
>                 static const float verts[] = {
> --
> 1.9.1
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list