[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tccgen.c: off by one in flexible array members

From: Michael Matz
Subject: Re: [Tinycc-devel] tccgen.c: off by one in flexible array members
Date: Fri, 11 Mar 2016 22:38:11 +0100 (CET)
User-agent: Alpine 2.20 (LSU 67 2015-01-07)


On Fri, 11 Mar 2016, Michael Matz wrote:

it's now "size += -1 * 4 + 1" (i.e. +=3).

-=3 of course, but you got the idea :)

So, I think it's more correct to special case the ref->c == -1 case only (don't adjust size in that case), instead of playing +-1 tricks (as in, it's not a off-by-one error). Will think a bit over dinner :)

After dinner I still agree with me :)  Pushed with a testcase.

This whole thing also points out some deficiencies of tcc to emit error messages. For instance it accepts the initialization

void f(void) {
  struct w q = {"bugs", { 'c' } };

(and sets ref->c to 1), even though this is a non-static initialization, which is wrong (but the size adjustments needs also to be done for static initialization). Probably this code can be simplified somewhat, but that's for somewhen else.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]