[Ffmpeg-devel] gcc 2.95 doesn't like snow.c

Rich Felker dalias
Fri Dec 30 21:22:53 CET 2005


On Fri, Dec 30, 2005 at 06:08:52PM +0100, Fran?ois Revol wrote:
> > On Fri, Dec 30, 2005 at 05:36:00PM +0100, Fran?ois Revol wrote:
> > > libavcodec/snow.c:3174: invalid use of non-lvalue array
> > >
> > > either it's a gcc3 extention or whatever, but it doesn't work here.
> > > I worked around it that way:
> > >
> > > - check_block(s, mb_x, mb_y, (int[2]){block->mx, block->my}, 0, &
> > > best_rd);
> >
> > It's a compound literal, which is a standard feature of C99.  Note
> > that it does create an lvalue (for example the array can be modified
> > by the called function, and in general you can take the address of a
> > compound literal).
> 
> Well fact is it doesn't work with 2.95.

Yes, gcc 2.95 seems to only partially support compound literals. I
discovered last night that its support for variable-length arrays of
structures is also hopelessly broken. :( Any volunteers to make
gcc-2.97? (2.97 = 2.95 with fixes for broken/missing c99
functionality).

> > > + check_block(s, mb_x, mb_y, ({int p[2] = {block->mx, block->my};
> > > p;}),
> > > 0, &best_rd);
> >
> > Now _that_ is using a gcc extension ;-)
> 
> Yes but _that_ works. :P

IMO it does not work. The scope of the variable p has ended by the
time it is used, and its space on the stack may no longer belong to
it. Why not use the clean, portable:

{ int p[2] = {block->mx, block->my};
  check_block(s, mb_x, mb_y, p, 0, &best_rd); }

Rich





More information about the ffmpeg-devel mailing list