yynerrs_ set but not used

"James K. Lowden" <[email protected]> Thu, 29 Jan 2026 14:24:36 -0500
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
I converted one of my parsers to generate C++.  I'm seeing a warning
that makes me wonder if I should do something differently.  I am using:

    %define api.location.type {cbl_loc_t}
    %require "3.5.1"  //    3.8.2 also works, but not 3.8.0
    %language "c++"
    %define api.prefix {ydf}
    %define api.token.prefix{YDF_}
    %locations
    %define parse.error verbose

where cbl_loc_t looks just like the default YYLTYPE.

The warning is:

cdf.cc: In member function ?virtual int ydf::parser::parse()?:
cdf.cc:595:9: warning: variable ?yynerrs_?=20
		set but not used [-Wunused-but-set-variable=3D]
  595 |     int yynerrs_ =3D 0;
      |         ^~~~~~~~

The compiler has two parsers.  I intend them both to use the same
error function:=20

	void yyerror( const char gmsgid[], ... );

which increments my own error count, independent of the generated
parser.  So I don't think I *need* parser::parser::yynerrs_.  But I
also don't know how I could use it if I wanted to. =20

$ bison --version
bison (GNU Bison) 3.8.2

Thank you.

--jkl