help-bison
[Top][All Lists]
Advanced

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

Re: set_goto_map() has unintentional ++ operator


From: Hans Aberg
Subject: Re: set_goto_map() has unintentional ++ operator
Date: Mon, 29 Dec 2014 23:06:55 +0100

> On 29 Dec 2014, at 22:40, sean nakasone <address@hidden> wrote:

> The placement of the ++ makes it a post increment, so it's incremented after 
> the statement, so it should not affect the value of k.
> 
> It's incrementing values in temp_map, but temp_map is deallocated after the 
> for loop, so that's why I thought it wasn't doing anything.
> 
>  for (s = 0; s < nstates; ++s)
>    {
>      transitions *sp = states[s]->transitions;
>      int i;
>      for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
>        {
>          goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
>          from_state[k] = s;
>          to_state[k] = sp->states[i]->number;
>        }
>    }
> 
>  free (temp_map);

It loops through the inner loop several times though, so the next time, the 
value has changed.





reply via email to

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