bison-patches
[Top][All Lists]
Advanced

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

Re: RFC: generate the default semantic action


From: Paul Eggert
Subject: Re: RFC: generate the default semantic action
Date: Sun, 14 Oct 2018 19:31:39 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

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

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