Akim Demaille wrote:

This patch is prompted by C++, but I believe it’s a real improvement
even for the other languages.  However, it does mean that the default
action is now made twice in C for instance.  I would very much like
to disable the pre-initialization of $$ to $1, but I’m afraid people
might depend on this…

As I recall, in the traditional Yacc implementation the default '$$ = $1;' action was implemented by doing nothing (i.e., zero C code and zero machine instructions), as $1 was the top value on the stack, so popping and pushing the stack was a no-op.

I also recall that at some point Bison put in an explicit '$$ = $1;', run before any action, because otherwise GCC complained in some cases (I think about uninitialized variables).

I don't know the motivation for doing the equivalent of '$$ = $1;' both before all actions, and explicitly for missing actions. I'm skeptical that we should do both, because in that case I expect that we'll miss some useful opportunities for GCC to generate warnings about uninitialized variables.

User code should not depend on any of these details; it should work even if we went back to the Yacc way of doing things, for C. Also, I wouldn't worry about any C code that does depend on these details, as I doubt whether there is any. So for the benefit of GCC warnings, I suggest just doing things the new way.

Reply via email to