Subject: bin/25065: flex generates bad C++ code
To: None <gnats-bugs@gnats.NetBSD.org>
From: Arne H. Juul <arnej@pvv.ntnu.no>
List: netbsd-bugs
Date: 04/05/2004 23:14:46
>Number:         25065
>Category:       bin
>Synopsis:       flex generates bad C++ code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 05 21:15:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Arne H Juul
>Release:        NetBSD 2.0B
>Organization:
        none
>Environment:

System: NetBSD blackbox 2.0B NetBSD 2.0B (BLACKBOX) #0: Sat Apr 3 02:19:13
CEST
2004 arnej@blackbox:/usr/obj/sys/arch/i386/compile/BLACKBOX i386
Architecture: i386
Machine: i386
>Description:
        When generating a lexer (actually from lilypond-2.2.0)
        using "%option c++" and "option debug" I got a C++ syntax
        error because the generated code used "std:endl" instead
        of "std::endl".
	Probably introduced by last commit which was:

	date: 2003/11/18 21:37:39;  author: christos;  state: Exp;  lines: +7 -7
	More g++-3 fixes:
        	- std:c{in,out,err}
       		- include <iostream>
        	- use std::endl instead of \n

>How-To-Repeat:
        Looks like this is only triggered with both %option c++
        and %option debug.
>Fix:
        The fix is trivial:

Index: gen.c
===================================================================
RCS file: /usr/cvs/src/usr.bin/lex/gen.c,v
retrieving revision 1.17
diff -u -r1.17 gen.c
--- gen.c	18 Nov 2003 21:37:39 -0000	1.17
+++ gen.c	5 Apr 2004 22:48:40 -0000
@@ -1436,7 +1436,7 @@
 		indent_puts( "if ( yy_act == 0 )" );
 		indent_up();
 		indent_puts( C_plus_plus ?
-			"std::cerr << \"--scanner backing up\" << std:endl;" :
+			"std::cerr << \"--scanner backing up\" << std::endl;" :
 			"fprintf( stderr, \"--scanner backing up\\n\" );" );
 		indent_down();
>Release-Note:
>Audit-Trail:
>Unformatted:
 
  -current cvsupped 05 Apr 2004.