Using bison to generate C++ code has a problem compiling a file, parser.y, with the command: bison -d -S lalr1.cc -o parser.cpp parser.y causes an error in compiling the code with g++. The error is a because at line 384 and 523 in /usr/share/bison/lalr1.cc the lines are not wrapped with #if YYDEBUG and an #endif Reproducible: Always Steps to Reproduce: 1. Call bison: bison -d -S lalr1.cc -o parser.cpp parser.y 2. Make: g++ parser.cpp Actual Results: parser.cpp: In member function `virtual int yy::Parser::parse()': parser.cpp:116: error: `name_' undeclared (first use this function) parser.cpp:116: error: (Each undeclared identifier is reported only once for each function it appears in.) parser.cpp: At global scope: parser.cpp:386: warning: initialization of negative value `-1' to `const unsigned char' parser.cpp:386: warning: argument of negative value `-1' to `unsigned char' Expected Results: File compiles with error or warnings. I cannot see why g++ is complaining about the warning. I personally hate warnings so I would like to squash it.
Created attachment 28716 [details] Bison grammar file which shows the error.
Sorry. Adding emerge info: Portage 2.0.50-r1 (default-x86-1.4, gcc-3.3.2, glibc-2.3.2-r9, 2.4.22-Libertos) ================================================================= System uname: 2.4.22-Libertos i686 Pentium III (Katmai) Gentoo Base System version 1.4.3.13 distcc 2.12.1 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled] ccache version 2.3 [enabled] Autoconf: sys-devel/autoconf-2.58-r1 Automake: sys-devel/automake-1.8.3 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CFLAGS="-march=pentium3 -O3 -pipe" CHOST="i686-pc-linux-gnu" COMPILER="gcc3" CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.1/share/config /usr/kde/3.2/share/config /usr/kde/3/share/config /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-march=pentium3 -O3 -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs ccache fixpackages sandbox" GENTOO_MIRRORS="http://gentoo.oregonstate.edu http://distro.ibiblio.org/pub/Linux/distributions/gentoo" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage" USE="X alsa apm arts avi berkdb bonobo cdr crypt cups curl doc encode esd flash foomaticdb gd gdbm gif gnome gpm gtk gtk2 gtkhtml guile imlib java jpeg kde ldap libg++ libwww mad mikmod mmx motif mozilla mpeg mysql ncurses nls oggvorbis opengl oss pam pdflib perl php plotutils png python qt quicktime readline sdl slang snmp spell ssl svga tcltk tcpd tetex truetype x86 xml2 xmms xv zlib"
bison version: sys-devel/bison-1.875 +nls -static
This problem seems to be resolved with the newest stable version of bison in the tree, bison-1.875d. Please reopen if you are still having problems.