Fix sent to bison-patches,
https://lists.gnu.org/archive/html/bison-patches/2025-07/msg00000.html
On 7/12/2025 8:35 AM, Z. Majeed wrote:
The api.value.automove directive doesn't honor an explicit false setting.
-------------------------------------------
// test_automove.y
%skeleton "lalr1.cc"
%require "3.8"
%language "c++"
%define api.value.automove false
%token <int> VAL
%nterm <int> x
%%
x: VAL
-------------------------------------------
bison -o test_automove.cpp test_automove.y
grep -B2 "yylhs.value.int" test_automove.cpp
case 2: // x: VAL
#line 14 "test_automove.y"
{ (yylhs.value.int) = YY_MOVE ((yystack_[0].value.int)); }
bison --version
bison (GNU Bison) 3.8.2
-------------------------------------------
The problem is in skeletons/lalr1.cc where b4_percent_define_ifdef
applies YY_MOVE as long as api.value.automove is defined without
considering its value
The default value of api.value.automove is false - omitting the
directive does prevent YY_MOVE from being applied
m4_define([b4_rhs_value],
[b4_percent_define_ifdef([api.value.automove],
[YY_MOVE (_b4_rhs_value($@))],
[_b4_rhs_value($@)])])
-------------------------------------------
b4_percent_define_ifdef is defined in skeletons/bison.m4
# _b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])
# ------------------------------------------------------
# If the %define variable VARIABLE is defined, expand IF-TRUE, else expand
# IF-FALSE. Don't record usage of VARIABLE.
-------------------------------------------
I'll send a fix for lalr1.cc shortly to bison-patches that looks like this
111a112,114
> # api.value.automove boolean default value false
> b4_percent_define_default([[api.value.automove]], [[false]])
>
113,115c116,118
< [b4_percent_define_ifdef([api.value.automove],
< [YY_MOVE (_b4_rhs_value($@))],
< [_b4_rhs_value($@)])])
---
> [b4_percent_define_flag_if([api.value.automove],
> [YY_MOVE (_b4_rhs_value($@))],
> [_b4_rhs_value($@)])])
Zartaj